Patch "rapidio: rio: fix possible name leak in rio_register_mport()" has been added to the 5.15-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

    rapidio: rio: fix possible name leak in rio_register_mport()

to the 5.15-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:
     rapidio-rio-fix-possible-name-leak-in-rio_register_m.patch
and it can be found in the queue-5.15 subdirectory.

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



commit f15583ba9aad6eb2a50c21b58ea9d3127d3c9a54
Author: Yang Yingliang <yangyingliang@xxxxxxxxxx>
Date:   Mon Nov 14 23:26:36 2022 +0800

    rapidio: rio: fix possible name leak in rio_register_mport()
    
    [ Upstream commit e92a216d16bde65d21a3227e0fb2aa0794576525 ]
    
    If device_register() returns error, the name allocated by dev_set_name()
    need be freed.  It should use put_device() to give up the reference in the
    error path, so that the name can be freed in kobject_cleanup(), and
    list_del() is called to delete the port from rio_mports.
    
    Link: https://lkml.kernel.org/r/20221114152636.2939035-3-yangyingliang@xxxxxxxxxx
    Fixes: 2aaf308b95b2 ("rapidio: rework device hierarchy and introduce mport class of devices")
    Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx>
    Cc: Alexandre Bounine <alex.bou9@xxxxxxxxx>
    Cc: Matt Porter <mporter@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/rapidio/rio.c b/drivers/rapidio/rio.c
index e74cf09eeff0..9544b8ee0c96 100644
--- a/drivers/rapidio/rio.c
+++ b/drivers/rapidio/rio.c
@@ -2186,11 +2186,16 @@ int rio_register_mport(struct rio_mport *port)
 	atomic_set(&port->state, RIO_DEVICE_RUNNING);
 
 	res = device_register(&port->dev);
-	if (res)
+	if (res) {
 		dev_err(&port->dev, "RIO: mport%d registration failed ERR=%d\n",
 			port->id, res);
-	else
+		mutex_lock(&rio_mport_list_lock);
+		list_del(&port->node);
+		mutex_unlock(&rio_mport_list_lock);
+		put_device(&port->dev);
+	} else {
 		dev_dbg(&port->dev, "RIO: registered mport%d\n", port->id);
+	}
 
 	return res;
 }



[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