|
@@ -56,7 +56,14 @@ static inline int device_is_not_partition(struct device *dev)
|
|
|
*/
|
|
|
const char *dev_driver_string(const struct device *dev)
|
|
|
{
|
|
|
- return dev->driver ? dev->driver->name :
|
|
|
+ struct device_driver *drv;
|
|
|
+
|
|
|
+ /* dev->driver can change to NULL underneath us because of unbinding,
|
|
|
+ * so be careful about accessing it. dev->bus and dev->class should
|
|
|
+ * never change once they are set, so they don't need special care.
|
|
|
+ */
|
|
|
+ drv = ACCESS_ONCE(dev->driver);
|
|
|
+ return drv ? drv->name :
|
|
|
(dev->bus ? dev->bus->name :
|
|
|
(dev->class ? dev->class->name : ""));
|
|
|
}
|