linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bus: fsl-mc: fix device reference leak in fsl_mc_device_lookup()
@ 2025-10-23 15:05 Wentao Liang
  2025-10-24 13:07 ` Ioana Ciornei
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2025-10-23 15:05 UTC (permalink / raw)
  To: ioana.ciornei; +Cc: linuxppc-dev, linux-kernel, Wentao Liang, stable

The device_find_child() function calls the get_device() and returns a
device reference that must be properly released when no longer needed.
The fsl_mc_device_lookup() directly returns without releasing the
reference via put_device().

Add the missing put_device() call to prevent reference leaks.

Fixes: f2f2726b62f5 ("staging: fsl-mc: Device driver for FSL-MC DPRC devices")
Cc: stable@vger.kernel.org # v4.1+
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/bus/fsl-mc/dprc-driver.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/fsl-mc/dprc-driver.c b/drivers/bus/fsl-mc/dprc-driver.c
index c63a7e688db6..e92c75cef90c 100644
--- a/drivers/bus/fsl-mc/dprc-driver.c
+++ b/drivers/bus/fsl-mc/dprc-driver.c
@@ -124,11 +124,17 @@ struct fsl_mc_device *fsl_mc_device_lookup(struct fsl_mc_obj_desc *obj_desc,
 					   struct fsl_mc_device *mc_bus_dev)
 {
 	struct device *dev;
+	struct fsl_mc_device *mc_dev;
 
 	dev = device_find_child(&mc_bus_dev->dev, obj_desc,
 				__fsl_mc_device_match);
+	if (!dev)
+		return NULL;
+
+	mc_dev = to_fsl_mc_device(dev);
+	put_device(dev);
 
-	return dev ? to_fsl_mc_device(dev) : NULL;
+	return mc_dev;
 }
 
 /**
-- 
2.42.0.windows.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-10-24 13:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-23 15:05 [PATCH] bus: fsl-mc: fix device reference leak in fsl_mc_device_lookup() Wentao Liang
2025-10-24 13:07 ` Ioana Ciornei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).