Skip to content

Commit e64daad

Browse files
ahunter6gregkh
authored andcommitted
driver core: Prevent warning when removing a device link from unregistered consumer
sysfs_remove_link() causes a warning if the parent directory does not exist. That can happen if the device link consumer has not been registered. So do not attempt sysfs_remove_link() in that case. Fixes: 287905e ("driver core: Expose device link details in sysfs") Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: stable@vger.kernel.org # 5.9+ Reviewed-by: Rafael J. Wysocki <rafael@kernel.org> Link: https://lore.kernel.org/r/20210716114408.17320-2-adrian.hunter@intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4afa0c2 commit e64daad

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

drivers/base/core.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,10 @@ static void devlink_remove_symlinks(struct device *dev,
574574
return;
575575
}
576576

577-
snprintf(buf, len, "supplier:%s:%s", dev_bus_name(sup), dev_name(sup));
578-
sysfs_remove_link(&con->kobj, buf);
577+
if (device_is_registered(con)) {
578+
snprintf(buf, len, "supplier:%s:%s", dev_bus_name(sup), dev_name(sup));
579+
sysfs_remove_link(&con->kobj, buf);
580+
}
579581
snprintf(buf, len, "consumer:%s:%s", dev_bus_name(con), dev_name(con));
580582
sysfs_remove_link(&sup->kobj, buf);
581583
kfree(buf);

0 commit comments

Comments
 (0)