public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fsi: Fix device refcount leak in i2cr_scom_probe
@ 2025-11-07  3:21 Ma Ke
  2025-11-07  8:50 ` Markus Elfring
  0 siblings, 1 reply; 3+ messages in thread
From: Ma Ke @ 2025-11-07  3:21 UTC (permalink / raw)
  To: eajames, ninad, joel; +Cc: linux-fsi, linux-kernel, akpm, Ma Ke, stable

This patch fixes a device reference count leak in the i2cr_scom driver
by adding proper put_device() calls in both error paths and the remove
function.

Found by code review.

Cc: stable@vger.kernel.org
Fixes: c0b34bed0bbf ("fsi: Add I2C Responder SCOM driver")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
---
 drivers/fsi/i2cr-scom.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/fsi/i2cr-scom.c b/drivers/fsi/i2cr-scom.c
index cb7e02213032..11506d321d7e 100644
--- a/drivers/fsi/i2cr-scom.c
+++ b/drivers/fsi/i2cr-scom.c
@@ -104,14 +104,20 @@ static int i2cr_scom_probe(struct device *dev)
 
 	ret = fsi_get_new_minor(fsi_dev, fsi_dev_scom, &scom->dev.devt, &didx);
 	if (ret)
-		return ret;
+		goto err_put_device;
 
 	dev_set_name(&scom->dev, "scom%d", didx);
 	cdev_init(&scom->cdev, &i2cr_scom_fops);
 	ret = cdev_device_add(&scom->cdev, &scom->dev);
 	if (ret)
-		fsi_free_minor(scom->dev.devt);
+		goto err_free_minor;
+
+	return ret;
 
+err_free_minor:
+	fsi_free_minor(scom->dev.devt);
+err_put_device:
+	put_device(&scom->dev);
 	return ret;
 }
 
-- 
2.17.1


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

end of thread, other threads:[~2025-11-08  1:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-07  3:21 [PATCH] fsi: Fix device refcount leak in i2cr_scom_probe Ma Ke
2025-11-07  8:50 ` Markus Elfring
2025-11-08  1:25   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox