driver core: Fix device link device name collision
commit e020ff611ba9be54e959e6b548038f8a020da1c9 upstream.
The device link device's name was of the form:
<supplier-dev-name>--<consumer-dev-name>
This can cause name collision as reported here [1] as device names are
not globally unique. Since device names have to be unique within the
bus/class, add the bus/class name as a prefix to the device names used to
construct the device link device name.
So the devuce link device's name will be of the form:
<supplier-bus-name>:<supplier-dev-name>--<consumer-bus-name>:<consumer-dev-name>
[1] - https://lore.kernel.org/lkml/20201229033440.32142-1-michael@walle.cc/
Fixes: 287905e68d
("driver core: Expose device link details in sysfs")
Cc: stable@vger.kernel.org
Reported-by: Michael Walle <michael@walle.cc>
Tested-by: Michael Walle <michael@walle.cc>
Signed-off-by: Saravana Kannan <saravanak@google.com>
Link: https://lore.kernel.org/r/20210110175408.1465657-1-saravanak@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
8cd3c48c1b
commit
b3bc56e3f5
@@ -615,6 +615,18 @@ static inline const char *dev_name(const struct device *dev)
|
||||
return kobject_name(&dev->kobj);
|
||||
}
|
||||
|
||||
/**
|
||||
* dev_bus_name - Return a device's bus/class name, if at all possible
|
||||
* @dev: struct device to get the bus/class name of
|
||||
*
|
||||
* Will return the name of the bus/class the device is attached to. If it is
|
||||
* not attached to a bus/class, an empty string will be returned.
|
||||
*/
|
||||
static inline const char *dev_bus_name(const struct device *dev)
|
||||
{
|
||||
return dev->bus ? dev->bus->name : (dev->class ? dev->class->name : "");
|
||||
}
|
||||
|
||||
__printf(2, 3) int dev_set_name(struct device *dev, const char *name, ...);
|
||||
|
||||
#ifdef CONFIG_NUMA
|
||||
|
Reference in New Issue
Block a user