diff --git a/drivers/base/core.c b/drivers/base/core.c index d67e7d8ff600..50bece594b36 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -425,8 +425,10 @@ static void devlink_remove_symlinks(struct device *dev, return; } - snprintf(buf, len, "supplier:%s", dev_name(sup)); - sysfs_remove_link(&con->kobj, buf); + if (device_is_registered(con)) { + snprintf(buf, len, "supplier:%s", dev_name(sup)); + sysfs_remove_link(&con->kobj, buf); + } snprintf(buf, len, "consumer:%s", dev_name(con)); sysfs_remove_link(&sup->kobj, buf); kfree(buf);