Patch "Drivers: hv: vmbus: fix possible memory leak in vmbus_device_register()" has been added to the 5.4-stable tree

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

 



This is a note to let you know that I've just added the patch titled

    Drivers: hv: vmbus: fix possible memory leak in vmbus_device_register()

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     drivers-hv-vmbus-fix-possible-memory-leak-in-vmbus_d.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 338faafb28da68b309c8904a0b71deb517898026
Author: Yang Yingliang <yangyingliang@xxxxxxxxxx>
Date:   Sat Nov 19 16:11:35 2022 +0800

    Drivers: hv: vmbus: fix possible memory leak in vmbus_device_register()
    
    [ Upstream commit 25c94b051592c010abe92c85b0485f1faedc83f3 ]
    
    If device_register() returns error in vmbus_device_register(),
    the name allocated by dev_set_name() must be freed. As comment
    of device_register() says, it should use put_device() to give
    up the reference in the error path. So fix this by calling
    put_device(), then the name can be freed in kobject_cleanup().
    
    Fixes: 09d50ff8a233 ("Staging: hv: make the Hyper-V virtual bus code build")
    Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx>
    Reviewed-by: Michael Kelley <mikelley@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20221119081135.1564691-3-yangyingliang@xxxxxxxxxx
    Signed-off-by: Wei Liu <wei.liu@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index d4c5efc6e157..a1cfa7596853 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -1863,6 +1863,7 @@ int vmbus_device_register(struct hv_device *child_device_obj)
 	ret = device_register(&child_device_obj->device);
 	if (ret) {
 		pr_err("Unable to register child device\n");
+		put_device(&child_device_obj->device);
 		return ret;
 	}
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux