possible leak at subsys_system_register fail path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <devendra.aaru@xxxxxxxxx>
---

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
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux