Skip to content

Commit 2831eeb

Browse files
ahunter6gregkh
authored andcommitted
driver core: Prevent warning when removing a device link from unregistered consumer
commit e64daad upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0e75938 commit 2831eeb

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
@@ -449,8 +449,10 @@ static void devlink_remove_symlinks(struct device *dev,
449449
return;
450450
}
451451

452-
snprintf(buf, len, "supplier:%s:%s", dev_bus_name(sup), dev_name(sup));
453-
sysfs_remove_link(&con->kobj, buf);
452+
if (device_is_registered(con)) {
453+
snprintf(buf, len, "supplier:%s:%s", dev_bus_name(sup), dev_name(sup));
454+
sysfs_remove_link(&con->kobj, buf);
455+
}
454456
snprintf(buf, len, "consumer:%s:%s", dev_bus_name(con), dev_name(con));
455457
sysfs_remove_link(&sup->kobj, buf);
456458
kfree(buf);

0 commit comments

Comments
 (0)