Skip to contentSkip to conversation

rapidio-rio-fix-possible-name-leak-in-rio_register_mport.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Dec 1, 2022

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: rapidio: rio: fix possible name leak in rio_register_mport()
has been removed from the -mm tree. Its filename was
rapidio-rio-fix-possible-name-leak-in-rio_register_mport.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Yang Yingliang <[email protected]>
Subject: rapidio: rio: fix possible name leak in rio_register_mport()
Date: Mon, 14 Nov 2022 23:26:36 +0800

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.

Fixes 2aaf308b95b2 ("rapidio: rework device hierarchy and introduce mport class of devices")
Cc Alexandre Bounine <[email protected]>
Cc Matt Porter <[email protected]>

---

 drivers/rapidio/rio.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/rapidio/rio.c renamed from drivers/rapidio/rio.c~rapidio-rio-fix-possible-name-leak-in-rio_register_mport +7 -2
@@ -2186,11 +2186,16 @@ int rio_register_mport(struct rio_mport
 	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;
 }

_

Patches currently in -mm which might be from [email protected] are