|
25 | 25 | #include <linux/mutex.h>
|
26 | 26 | #include <linux/pm_runtime.h>
|
27 | 27 | #include <linux/netdevice.h>
|
| 28 | +#include <linux/rcupdate.h> |
28 | 29 | #include <linux/sched/signal.h>
|
29 | 30 | #include <linux/sched/mm.h>
|
30 | 31 | #include <linux/string_helpers.h>
|
@@ -2565,6 +2566,7 @@ static const char *dev_uevent_name(const struct kobject *kobj)
|
2565 | 2566 | static int dev_uevent(const struct kobject *kobj, struct kobj_uevent_env *env)
|
2566 | 2567 | {
|
2567 | 2568 | const struct device *dev = kobj_to_dev(kobj);
|
| 2569 | + struct device_driver *driver; |
2568 | 2570 | int retval = 0;
|
2569 | 2571 |
|
2570 | 2572 | /* add device node properties if present */
|
@@ -2593,8 +2595,12 @@ static int dev_uevent(const struct kobject *kobj, struct kobj_uevent_env *env)
|
2593 | 2595 | if (dev->type && dev->type->name)
|
2594 | 2596 | add_uevent_var(env, "DEVTYPE=%s", dev->type->name);
|
2595 | 2597 |
|
2596 |
| - if (dev->driver) |
2597 |
| - add_uevent_var(env, "DRIVER=%s", dev->driver->name); |
| 2598 | + /* Synchronize with module_remove_driver() */ |
| 2599 | + rcu_read_lock(); |
| 2600 | + driver = READ_ONCE(dev->driver); |
| 2601 | + if (driver) |
| 2602 | + add_uevent_var(env, "DRIVER=%s", driver->name); |
| 2603 | + rcu_read_unlock(); |
2598 | 2604 |
|
2599 | 2605 | /* Add common DT information about the device */
|
2600 | 2606 | of_device_uevent(dev, env);
|
@@ -2664,11 +2670,8 @@ static ssize_t uevent_show(struct device *dev, struct device_attribute *attr,
|
2664 | 2670 | if (!env)
|
2665 | 2671 | return -ENOMEM;
|
2666 | 2672 |
|
2667 |
| - /* Synchronize with really_probe() */ |
2668 |
| - device_lock(dev); |
2669 | 2673 | /* let the kset specific function add its keys */
|
2670 | 2674 | retval = kset->uevent_ops->uevent(&dev->kobj, env);
|
2671 |
| - device_unlock(dev); |
2672 | 2675 | if (retval)
|
2673 | 2676 | goto out;
|
2674 | 2677 |
|
|
0 commit comments