]> git.baikalelectronics.ru Git - kernel.git/commit
cxl/mem: Do not rely on device_add() side effects for dev_set_name() failures
authorDan Williams <dan.j.williams@intel.com>
Thu, 1 Apr 2021 14:33:25 +0000 (07:33 -0700)
committerDan Williams <dan.j.williams@intel.com>
Tue, 6 Apr 2021 18:41:30 +0000 (11:41 -0700)
commit5a5e9933100ff03757293fb1e32fc8fb0bd0b2a9
tree67fd629f9d6b50214644239e585e84fddacda935
parenta712f8e6da256157aab58d46a7532efc3a364801
cxl/mem: Do not rely on device_add() side effects for dev_set_name() failures

While device_add() will happen to catch dev_set_name() failures it is a
broken pattern to follow given that the core may try to fall back to a
different name.

Add explicit checking for dev_set_name() failures to be cleaned up by
put_device(). Skip cdev_device_add() and proceed directly to
put_device() if the name set fails.

This type of bug is easier to see if 'alloc' is split from 'add'
operations that require put_device() on failure. So cxl_memdev_alloc()
is split out as a result.

Fixes: e6a212030d26 ("cxl/mem: Register CXL memX devices")
Reported-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/161728760514.2474381.1163928273337158134.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/cxl/mem.c