Yi Yang wrote:
> It will cause null-ptr-deref when nd_dax_alloc() returns NULL, fix it by
> add check for nd_dax_alloc().
Was this found with a real workload or just by inspection?
Ira
>
> Fixes: c5ed9268643c ("libnvdimm, dax: autodetect support")
> Signed-off-by: Yi Yang <[email protected]>
> ---
> drivers/nvdimm/dax_devs.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/nvdimm/dax_devs.c b/drivers/nvdimm/dax_devs.c
> index 6b4922de3047..70a7e401f90d 100644
> --- a/drivers/nvdimm/dax_devs.c
> +++ b/drivers/nvdimm/dax_devs.c
> @@ -106,6 +106,10 @@ int nd_dax_probe(struct device *dev, struct
> nd_namespace_common *ndns)
>
> nvdimm_bus_lock(&ndns->dev);
> nd_dax = nd_dax_alloc(nd_region);
> + if (!nd_dax) {
> + nvdimm_bus_unlock(&ndns->dev);
> + return -ENOMEM;
> + }
> nd_pfn = &nd_dax->nd_pfn;
> dax_dev = nd_pfn_devinit(nd_pfn, ndns);
> nvdimm_bus_unlock(&ndns->dev);
> --
> 2.25.1
>
>