]> git.baikalelectronics.ru Git - kernel.git/commit
cxl: Fix cleanup of port devices on failure to probe driver.
authorJonathan Cameron <Jonathan.Cameron@huawei.com>
Thu, 9 Jun 2022 13:45:19 +0000 (14:45 +0100)
committerDan Williams <dan.j.williams@intel.com>
Tue, 21 Jun 2022 21:09:00 +0000 (14:09 -0700)
commitac793d6218ef05d6f172e6eef4db19cd451219e2
tree1e48080a653c3805ee8e80b7023bb59d87190154
parent5065fe058e80260394283e9f1c8b67724aa1c0b2
cxl: Fix cleanup of port devices on failure to probe driver.

The device is created, and then there is a check if a driver succesfully
bound to it. In event of failing the bind (e.g. failure in cxl_port_probe())
the device is left registered. When a bus rescan later occurs, fresh
devices are created leading to a multiple device representing the same
underlying hardware. Bad things may follow and at very least we have far too many
devices.

Fix by ensuring autoremove is registered if the device create succeeds,
but doesn't depend on sucessful binding to a driver.

Bug was observed as side effect of incorrect ownership in
[PATCH v9 6/9] cxl/port: Read CDAT table
but will result from any failure to in cxl_port_probe().

Fixes: 5a298866c510 ("cxl/mem: Add the cxl_mem driver")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Link: https://lore.kernel.org/r/20220609134519.11668-1-Jonathan.Cameron@huawei.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/cxl/mem.c