Skip to content

Commit 1d59768

Browse files
committed
Merge tag 'driver-core-5.14-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core fixes from Greg KH: "Here are two small driver core fixes to resolve some reported problems for 5.14-rc3. They include: - aux bus memory leak fix - unneeded warning message removed when removing a device link. Both have been in linux-next with no reported problems" * tag 'driver-core-5.14-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: driver core: Prevent warning when removing a device link from unregistered consumer driver core: auxiliary bus: Fix memory leak when driver_register() fail
2 parents 8072911 + e64daad commit 1d59768

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

drivers/base/auxiliary.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ EXPORT_SYMBOL_GPL(auxiliary_find_device);
231231
int __auxiliary_driver_register(struct auxiliary_driver *auxdrv,
232232
struct module *owner, const char *modname)
233233
{
234+
int ret;
235+
234236
if (WARN_ON(!auxdrv->probe) || WARN_ON(!auxdrv->id_table))
235237
return -EINVAL;
236238

@@ -246,7 +248,11 @@ int __auxiliary_driver_register(struct auxiliary_driver *auxdrv,
246248
auxdrv->driver.bus = &auxiliary_bus_type;
247249
auxdrv->driver.mod_name = modname;
248250

249-
return driver_register(&auxdrv->driver);
251+
ret = driver_register(&auxdrv->driver);
252+
if (ret)
253+
kfree(auxdrv->driver.name);
254+
255+
return ret;
250256
}
251257
EXPORT_SYMBOL_GPL(__auxiliary_driver_register);
252258

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)