while device_register fail occur it goes into the err_dev_reg, and
makes dev pointer as null which is alloced causing a leak,

possibly the following patch will fix the issue but not sure about
whether this is right or wrong, just wanted to report.

--------------------
driver: base: fix a leak while the device_register fail

we leak the memory allocated to dev struct since the dev is assigned
to null before kfree in the error path of the code.

Signed-Off-By: Devendra Naga <[email protected]>
---

diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 181ed26..93c2a38 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -1270,9 +1270,9 @@ int subsys_system_register(struct bus_type *subsys,

 err_dev_reg:
        put_device(dev);
-       dev = NULL;
 err_name:
        kfree(dev);
+       dev = NULL;
 err_dev:
        bus_unregister(subsys);
        return err;
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

Reply via email to