Skip to contentSkip to conversation

fsi: Fix device refcount leak in i2cr_scom_probe

PATCH In review Ma Ke 3 participants 3 messages Nov 7, 2025 – Nov 8, 2025

Subsystems (2)
lore
Share & tools
lore

Ma Ke

author
#0 lore raw

PATCH 1/1 fsi: Fix device refcount leak in i2cr_scom_probe

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.

Fixes c0b34bed0bbf ("fsi: Add I2C Responder SCOM driver")
---
 drivers/fsi/i2cr-scom.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/fsi/i2cr-scom.c +8 -2
index cb7e02213032..11506d321d7e 100644
@@ -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;
 }
 
Signature · 1 line
2.17.1
maintainer
#2 lore raw
Quoted 10 lines · Markus Elfring
Quoted 1 line

This patch fixes a device reference count leak …

Would a corresponding imperative wording become helpful for an improved change description?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.18-rc4#n94

Would a summary phrase like “Fix reference count leak in i2cr_scom_probe()” be nicer?

Regards,
Markus

Hi,

This is the semi-friendly patch-bot of Greg Kroah-Hartman.

Markus, you seem to have sent a nonsensical or otherwise pointless review comment to a patch submission on a Linux kernel developer mailing list. I strongly suggest that you not do this anymore. Please do not bother developers who are actively working to produce patches and features with comments that, in the end, are a waste of time.

Patch submitter, please ignore Markus's suggestion; you do not need to follow it at all. The person/bot/AI that sent it is being ignored by almost all Linux kernel maintainers for having a persistent pattern of behavior of producing distracting and pointless commentary, and inability to adapt to feedback. Please feel free to also ignore emails from them.

thanks,

greg k-h's patch email bot