patch "driver core: auxiliary bus: Fix memory leak when driver_register()" added to driver-core-linus
Subsystems (3)
This is a note to let you know that I've just added the patch titled
driver core: auxiliary bus: Fix memory leak when driver_register()
to my driver-core git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git
in the driver-core-linus branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.
If you have any questions about this process, please let me know.
From 4afa0c22eed33cfe0c590742387f0d16f32412f3 Mon Sep 17 00:00:00 2001
From: Peter Ujfalusi <[email protected]>
Date: Tue, 13 Jul 2021 12:34:38 +0300
Subject: driver core: auxiliary bus: Fix memory leak when driver_register()
fail
If driver_register() returns with error we need to free the memory allocated for auxdrv->driver.name before returning from __auxiliary_driver_register()
--- drivers/base/auxiliary.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/base/auxiliary.c +7 -1
@@ -231,6 +231,8 @@ EXPORT_SYMBOL_GPL(auxiliary_find_device);int __auxiliary_driver_register (struct auxiliary_driver *auxdrv,struct module *owner,const char *modname) { +int ret; +if (WARN_ON (!auxdrv->probe) ||WARN_ON (!auxdrv->id_table))return -EINVAL ;
@@ -246,7 +248,11 @@ int __auxiliary_driver_register(struct auxiliary_driver *auxdrv, auxdrv->driver.bus = &auxiliary_bus_type; auxdrv->driver.mod_name = modname; -return driver_register (&auxdrv->driver); + ret =driver_register (&auxdrv->driver); +if (ret) +kfree (auxdrv->driver.name); + +return ret; }EXPORT_SYMBOL_GPL (__auxiliary_driver_register);
Signature · 1 line
2.32.0