Patch "NTB: ntb_transport: fix possible memory leak while device_register() fails" 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

    NTB: ntb_transport: fix possible memory leak while device_register() fails

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:
     ntb-ntb_transport-fix-possible-memory-leak-while-dev.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 7b07412afefa9dcd30ba063fc844a1f2104b6fae
Author: Yang Yingliang <yangyingliang@xxxxxxxxxx>
Date:   Thu Nov 10 23:19:17 2022 +0800

    NTB: ntb_transport: fix possible memory leak while device_register() fails
    
    [ Upstream commit 8623ccbfc55d962e19a3537652803676ad7acb90 ]
    
    If device_register() returns error, the name allocated by
    dev_set_name() need 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(), and client_dev is freed
    in ntb_transport_client_release().
    
    Fixes: fce8a7bb5b4b ("PCI-Express Non-Transparent Bridge Support")
    Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx>
    Reviewed-by: Dave Jiang <dave.jiang@xxxxxxxxx>
    Signed-off-by: Jon Mason <jdmason@xxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
index 9398959664769..2d647a1cd0ee5 100644
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -393,7 +393,7 @@ int ntb_transport_register_client_dev(char *device_name)
 
 		rc = device_register(dev);
 		if (rc) {
-			kfree(client_dev);
+			put_device(dev);
 			goto err;
 		}
 



[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