nvdimm/pmem: fix leak on dax_add_host() failure
Fix a leak on dax_add_host() error, where "goto out_cleanup_dax" is done before setting pmem->dax_dev, which therefore issues the two following calls on NULL pointers: out_cleanup_dax: kill_dax(pmem->dax_dev); put_dax(pmem->dax_dev); Link: https://lkml.kernel.org/r/20240208184913.484340-1-mathieu.desnoyers@efficios.com Link: https://lkml.kernel.org/r/20240208184913.484340-2-mathieu.desnoyers@efficios.com Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Reviewed-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Fan Ni <fan.ni@samsung.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Cc: Alasdair Kergon <agk@redhat.com> Cc: Mike Snitzer <snitzer@kernel.org> Cc: Mikulas Patocka <mpatocka@redhat.com> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Russell King <linux@armlinux.org.uk> Cc: Dave Chinner <david@fromorbit.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
f0c2264958
commit
f6932a2754
@ -566,12 +566,11 @@ static int pmem_attach_disk(struct device *dev,
|
|||||||
set_dax_nomc(dax_dev);
|
set_dax_nomc(dax_dev);
|
||||||
if (is_nvdimm_sync(nd_region))
|
if (is_nvdimm_sync(nd_region))
|
||||||
set_dax_synchronous(dax_dev);
|
set_dax_synchronous(dax_dev);
|
||||||
|
pmem->dax_dev = dax_dev;
|
||||||
rc = dax_add_host(dax_dev, disk);
|
rc = dax_add_host(dax_dev, disk);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto out_cleanup_dax;
|
goto out_cleanup_dax;
|
||||||
dax_write_cache(dax_dev, nvdimm_has_cache(nd_region));
|
dax_write_cache(dax_dev, nvdimm_has_cache(nd_region));
|
||||||
pmem->dax_dev = dax_dev;
|
|
||||||
|
|
||||||
rc = device_add_disk(dev, disk, pmem_attribute_groups);
|
rc = device_add_disk(dev, disk, pmem_attribute_groups);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto out_remove_host;
|
goto out_remove_host;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user