Skip to content

Commit fe10c83

Browse files
committed
Revert "driver core: Fix uevent_show() vs driver detach race"
commit 9a71892 upstream. 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 <[email protected]> Cc: Ashish Sangwan <[email protected]> Cc: Namjae Jeon <[email protected]> Cc: Dirk Behme <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Rafael J. Wysocki <[email protected]> Cc: Dan Williams <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d55d925 commit fe10c83

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
@@ -24,7 +24,6 @@
2424
#include <linux/mutex.h>
2525
#include <linux/pm_runtime.h>
2626
#include <linux/netdevice.h>
27-
#include <linux/rcupdate.h>
2827
#include <linux/sched/signal.h>
2928
#include <linux/sysfs.h>
3029

@@ -1138,7 +1137,6 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,
11381137
struct kobj_uevent_env *env)
11391138
{
11401139
struct device *dev = kobj_to_dev(kobj);
1141-
struct device_driver *driver;
11421140
int retval = 0;
11431141

11441142
/* add device node properties if present */
@@ -1167,12 +1165,8 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,
11671165
if (dev->type && dev->type->name)
11681166
add_uevent_var(env, "DEVTYPE=%s", dev->type->name);
11691167

1170-
/* Synchronize with module_remove_driver() */
1171-
rcu_read_lock();
1172-
driver = READ_ONCE(dev->driver);
1173-
if (driver)
1174-
add_uevent_var(env, "DRIVER=%s", driver->name);
1175-
rcu_read_unlock();
1168+
if (dev->driver)
1169+
add_uevent_var(env, "DRIVER=%s", dev->driver->name);
11761170

11771171
/* Add common DT information about the device */
11781172
of_device_uevent(dev, env);
@@ -1242,8 +1236,11 @@ static ssize_t uevent_show(struct device *dev, struct device_attribute *attr,
12421236
if (!env)
12431237
return -ENOMEM;
12441238

1239+
/* Synchronize with really_probe() */
1240+
device_lock(dev);
12451241
/* let the kset specific function add its keys */
12461242
retval = kset->uevent_ops->uevent(kset, &dev->kobj, env);
1243+
device_unlock(dev);
12471244
if (retval)
12481245
goto out;
12491246

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(struct device_driver *drv)
@@ -78,9 +77,6 @@ void module_remove_driver(struct device_driver *drv)
7877
if (!drv)
7978
return;
8079

81-
/* Synchronize with dev_uevent() */
82-
synchronize_rcu();
83-
8480
sysfs_remove_link(&drv->p->kobj, "module");
8581

8682
if (drv->owner)

0 commit comments

Comments
 (0)