Skip to content

Commit 9a71892

Browse files
committed
Revert "driver core: Fix uevent_show() vs driver detach race"
This reverts commit 15fffc6. 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: 15fffc6 ("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>
1 parent 8e929cb commit 9a71892

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

drivers/base/core.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <linux/of.h>
2727
#include <linux/of_device.h>
2828
#include <linux/pm_runtime.h>
29-
#include <linux/rcupdate.h>
3029
#include <linux/sched/mm.h>
3130
#include <linux/sched/signal.h>
3231
#include <linux/slab.h>
@@ -2634,7 +2633,6 @@ static const char *dev_uevent_name(const struct kobject *kobj)
26342633
static int dev_uevent(const struct kobject *kobj, struct kobj_uevent_env *env)
26352634
{
26362635
const struct device *dev = kobj_to_dev(kobj);
2637-
struct device_driver *driver;
26382636
int retval = 0;
26392637

26402638
/* add device node properties if present */
@@ -2663,12 +2661,8 @@ static int dev_uevent(const struct kobject *kobj, struct kobj_uevent_env *env)
26632661
if (dev->type && dev->type->name)
26642662
add_uevent_var(env, "DEVTYPE=%s", dev->type->name);
26652663

2666-
/* Synchronize with module_remove_driver() */
2667-
rcu_read_lock();
2668-
driver = READ_ONCE(dev->driver);
2669-
if (driver)
2670-
add_uevent_var(env, "DRIVER=%s", driver->name);
2671-
rcu_read_unlock();
2664+
if (dev->driver)
2665+
add_uevent_var(env, "DRIVER=%s", dev->driver->name);
26722666

26732667
/* Add common DT information about the device */
26742668
of_device_uevent(dev, env);
@@ -2738,8 +2732,11 @@ static ssize_t uevent_show(struct device *dev, struct device_attribute *attr,
27382732
if (!env)
27392733
return -ENOMEM;
27402734

2735+
/* Synchronize with really_probe() */
2736+
device_lock(dev);
27412737
/* let the kset specific function add its keys */
27422738
retval = kset->uevent_ops->uevent(&dev->kobj, env);
2739+
device_unlock(dev);
27432740
if (retval)
27442741
goto out;
27452742

drivers/base/module.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include <linux/errno.h>
88
#include <linux/slab.h>
99
#include <linux/string.h>
10-
#include <linux/rcupdate.h>
1110
#include "base.h"
1211

1312
static char *make_driver_name(const struct device_driver *drv)
@@ -102,9 +101,6 @@ void module_remove_driver(const struct device_driver *drv)
102101
if (!drv)
103102
return;
104103

105-
/* Synchronize with dev_uevent() */
106-
synchronize_rcu();
107-
108104
sysfs_remove_link(&drv->p->kobj, "module");
109105

110106
if (drv->owner)

0 commit comments

Comments
 (0)