From: Ma Ke <make24@iscas.ac.cn>
To: eajames@linux.ibm.com, ninad@linux.ibm.com, joel@jms.id.au
Cc: linux-fsi@lists.ozlabs.org, linux-kernel@vger.kernel.org,
akpm@linux-foundation.org, Ma Ke <make24@iscas.ac.cn>,
stable@vger.kernel.org
Subject: [PATCH] fsi: Fix device refcount leak in i2cr_scom_probe
Date: Fri, 7 Nov 2025 11:21:52 +0800 [thread overview]
Message-ID: <20251107032152.16835-1-make24@iscas.ac.cn> (raw)
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
next reply other threads:[~2025-11-07 3:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-07 3:21 Ma Ke [this message]
2025-11-07 8:50 ` [PATCH] fsi: Fix device refcount leak in i2cr_scom_probe Markus Elfring
2025-11-08 1:25 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251107032152.16835-1-make24@iscas.ac.cn \
--to=make24@iscas.ac.cn \
--cc=akpm@linux-foundation.org \
--cc=eajames@linux.ibm.com \
--cc=joel@jms.id.au \
--cc=linux-fsi@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ninad@linux.ibm.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.