This is a note to let you know that I've just added the patch titled driver core: Move driver_sysfs_remove() after driver_sysfs_add() to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: driver-core-move-driver_sysfs_remove-after-driver_sy.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 1e0d9ee2546f9ee4faf204e4e944f24773e472ac Author: Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx> Date: Fri Dec 31 11:39:00 2021 +0800 driver core: Move driver_sysfs_remove() after driver_sysfs_add() [ Upstream commit 885e50253bfd6750327a265405461496d6af1639 ] The driver_sysfs_remove() should be called after driver_sysfs_add() in really_probe(). The out-of-order driver_sysfs_remove() tries to remove some nonexistent nodes under the device and driver sysfs nodes. This is allowed, hence this change doesn't fix any problem, just a cleanup. Signed-off-by: Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx> Link: https://lore.kernel.org/r/20211231033901.2168664-2-baolu.lu@xxxxxxxxxxxxxxx Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Stable-dep-of: 2e84dc379200 ("driver core: Release all resources during unbind before updating device links") Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/base/dd.c b/drivers/base/dd.c index ab0b2eb5fa07f..f5371daf4fd29 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -576,14 +576,14 @@ static int really_probe(struct device *dev, struct device_driver *drv) if (dev->bus->dma_configure) { ret = dev->bus->dma_configure(dev); if (ret) - goto probe_failed; + goto sysfs_failed; } ret = driver_sysfs_add(dev); if (ret) { pr_err("%s: driver_sysfs_add(%s) failed\n", __func__, dev_name(dev)); - goto probe_failed; + goto sysfs_failed; } if (dev->pm_domain && dev->pm_domain->activate) { @@ -659,6 +659,8 @@ static int really_probe(struct device *dev, struct device_driver *drv) else if (drv->remove) drv->remove(dev); probe_failed: + driver_sysfs_remove(dev); +sysfs_failed: if (dev->bus) blocking_notifier_call_chain(&dev->bus->p->bus_notifier, BUS_NOTIFY_DRIVER_NOT_BOUND, dev); @@ -668,7 +670,6 @@ static int really_probe(struct device *dev, struct device_driver *drv) arch_teardown_dma_ops(dev); kfree(dev->dma_range_map); dev->dma_range_map = NULL; - driver_sysfs_remove(dev); dev->driver = NULL; dev_set_drvdata(dev, NULL); if (dev->pm_domain && dev->pm_domain->dismiss)