Patch "Drivers: hv: vmbus: fix double free in the error path of vmbus_add_channel_work()" has been added to the 4.19-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 double free in the error path of vmbus_add_channel_work()

to the 4.19-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-double-free-in-the-error-path-o.patch
and it can be found in the queue-4.19 subdirectory.

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



commit 80b5df01ca538aa0718717a33f880e47c5c5ad19
Author: Yang Yingliang <yangyingliang@xxxxxxxxxx>
Date:   Sat Nov 19 16:11:34 2022 +0800

    Drivers: hv: vmbus: fix double free in the error path of vmbus_add_channel_work()
    
    [ Upstream commit f92a4b50f0bd7fd52391dc4bb9a309085d278f91 ]
    
    In the error path of vmbus_device_register(), device_unregister()
    is called, which calls vmbus_device_release().  The latter frees
    the struct hv_device that was passed in to vmbus_device_register().
    So remove the kfree() in vmbus_add_channel_work() to avoid a double
    free.
    
    Fixes: c2e5df616e1a ("vmbus: add per-channel sysfs info")
    Suggested-by: Michael Kelley <mikelley@xxxxxxxxxxxxx>
    Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx>
    Reviewed-by: Michael Kelley <mikelley@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20221119081135.1564691-2-yangyingliang@xxxxxxxxxx
    Signed-off-by: Wei Liu <wei.liu@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index a3f6933f94e3..ccfa5ceb43c0 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -508,13 +508,17 @@ static void vmbus_add_channel_work(struct work_struct *work)
 	 * Add the new device to the bus. This will kick off device-driver
 	 * binding which eventually invokes the device driver's AddDevice()
 	 * method.
+	 *
+	 * If vmbus_device_register() fails, the 'device_obj' is freed in
+	 * vmbus_device_release() as called by device_unregister() in the
+	 * error path of vmbus_device_register(). In the outside error
+	 * path, there's no need to free it.
 	 */
 	ret = vmbus_device_register(newchannel->device_obj);
 
 	if (ret != 0) {
 		pr_err("unable to add child device object (relid %d)\n",
 			newchannel->offermsg.child_relid);
-		kfree(newchannel->device_obj);
 		goto err_deq_chan;
 	}
 



[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