|
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/swiotlb.h>
|
@@ -2558,6 +2559,7 @@ static const char *dev_uevent_name(struct kobject *kobj)
|
2558 | 2559 | static int dev_uevent(struct kobject *kobj, struct kobj_uevent_env *env)
|
2559 | 2560 | {
|
2560 | 2561 | struct device *dev = kobj_to_dev(kobj);
|
| 2562 | + struct device_driver *driver; |
2561 | 2563 | int retval = 0;
|
2562 | 2564 |
|
2563 | 2565 | /* add device node properties if present */
|
@@ -2586,8 +2588,12 @@ static int dev_uevent(struct kobject *kobj, struct kobj_uevent_env *env)
|
2586 | 2588 | if (dev->type && dev->type->name)
|
2587 | 2589 | add_uevent_var(env, "DEVTYPE=%s", dev->type->name);
|
2588 | 2590 |
|
2589 |
| - if (dev->driver) |
2590 |
| - add_uevent_var(env, "DRIVER=%s", dev->driver->name); |
| 2591 | + /* Synchronize with module_remove_driver() */ |
| 2592 | + rcu_read_lock(); |
| 2593 | + driver = READ_ONCE(dev->driver); |
| 2594 | + if (driver) |
| 2595 | + add_uevent_var(env, "DRIVER=%s", driver->name); |
| 2596 | + rcu_read_unlock(); |
2591 | 2597 |
|
2592 | 2598 | /* Add common DT information about the device */
|
2593 | 2599 | of_device_uevent(dev, env);
|
@@ -2657,11 +2663,8 @@ static ssize_t uevent_show(struct device *dev, struct device_attribute *attr,
|
2657 | 2663 | if (!env)
|
2658 | 2664 | return -ENOMEM;
|
2659 | 2665 |
|
2660 |
| - /* Synchronize with really_probe() */ |
2661 |
| - device_lock(dev); |
2662 | 2666 | /* let the kset specific function add its keys */
|
2663 | 2667 | retval = kset->uevent_ops->uevent(&dev->kobj, env);
|
2664 |
| - device_unlock(dev); |
2665 | 2668 | if (retval)
|
2666 | 2669 | goto out;
|
2667 | 2670 |
|
|
0 commit comments