]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Revert "driver core: Fix uevent_show() vs driver detach race"
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 29 Oct 2024 00:23:04 +0000 (01:23 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 29 Oct 2024 00:23:43 +0000 (01:23 +0100)
This reverts commit 15fffc6a5624b13b428bb1c6e9088e32a55eb82c.

This commit causes a regression, so revert it for now until it can come
back in a way that works for everyone.

Link: https://lore.kernel.org/all/172790598832.1168608.4519484276671503678.stgit@dwillia2-xfh.jf.intel.com/
Fixes: 15fffc6a5624 ("driver core: Fix uevent_show() vs driver detach race")
Cc: stable <stable@kernel.org>
Cc: Ashish Sangwan <a.sangwan@samsung.com>
Cc: Namjae Jeon <namjae.jeon@samsung.com>
Cc: Dirk Behme <dirk.behme@de.bosch.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/core.c
drivers/base/module.c

index a4c853411a6b2b767cfab2169ab2125ab803ca9c..adc0d74fa96c1e31e162f67f1eca4abf3bcacec6 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/pm_runtime.h>
-#include <linux/rcupdate.h>
 #include <linux/sched/mm.h>
 #include <linux/sched/signal.h>
 #include <linux/slab.h>
@@ -2634,7 +2633,6 @@ static const char *dev_uevent_name(const struct kobject *kobj)
 static int dev_uevent(const struct kobject *kobj, struct kobj_uevent_env *env)
 {
        const struct device *dev = kobj_to_dev(kobj);
-       struct device_driver *driver;
        int retval = 0;
 
        /* add device node properties if present */
@@ -2663,12 +2661,8 @@ static int dev_uevent(const struct kobject *kobj, struct kobj_uevent_env *env)
        if (dev->type && dev->type->name)
                add_uevent_var(env, "DEVTYPE=%s", dev->type->name);
 
-       /* Synchronize with module_remove_driver() */
-       rcu_read_lock();
-       driver = READ_ONCE(dev->driver);
-       if (driver)
-               add_uevent_var(env, "DRIVER=%s", driver->name);
-       rcu_read_unlock();
+       if (dev->driver)
+               add_uevent_var(env, "DRIVER=%s", dev->driver->name);
 
        /* Add common DT information about the device */
        of_device_uevent(dev, env);
@@ -2738,8 +2732,11 @@ static ssize_t uevent_show(struct device *dev, struct device_attribute *attr,
        if (!env)
                return -ENOMEM;
 
+       /* Synchronize with really_probe() */
+       device_lock(dev);
        /* let the kset specific function add its keys */
        retval = kset->uevent_ops->uevent(&dev->kobj, env);
+       device_unlock(dev);
        if (retval)
                goto out;
 
index c4eaa1158d54ed24a83860ffe587e7bf17c68ff7..5bc71bea883a06f0b10b064a242b1a0ebee35236 100644 (file)
@@ -7,7 +7,6 @@
 #include <linux/errno.h>
 #include <linux/slab.h>
 #include <linux/string.h>
-#include <linux/rcupdate.h>
 #include "base.h"
 
 static char *make_driver_name(const struct device_driver *drv)
@@ -102,9 +101,6 @@ void module_remove_driver(const struct device_driver *drv)
        if (!drv)
                return;
 
-       /* Synchronize with dev_uevent() */
-       synchronize_rcu();
-
        sysfs_remove_link(&drv->p->kobj, "module");
 
        if (drv->owner)