From: Miaoqian Lin <linmq006@gmail.com>
To: Lee Jones <lee@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
Thor Thayer <thor.thayer@linux.intel.com>,
linux-kernel@vger.kernel.org
Cc: linmq006@gmail.com, stable@vger.kernel.org
Subject: [PATCH] mfd: altera-sysmgr: Fix device reference leak in altr_sysmgr_regmap_lookup_by_phandle
Date: Tue, 28 Oct 2025 12:10:42 +0800 [thread overview]
Message-ID: <20251028041042.48874-1-linmq006@gmail.com> (raw)
driver_find_device_by_of_node() calls driver_find_device(), which calls
get_device(). get_device() increments the device's reference count,
so driver_find_device_by_of_node() returns a device
with its reference count incremented.
We need to release this reference after usage to avoid a reference leak.
Add put_device(dev) after dev_get_drvdata() to fix the reference leak.
Found via static analysis.
Fixes: f36e789a1f8d ("mfd: altera-sysmgr: Add SOCFPGA System Manager")
Cc: stable@vger.kernel.org
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
drivers/mfd/altera-sysmgr.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/mfd/altera-sysmgr.c b/drivers/mfd/altera-sysmgr.c
index fb5f988e61f3..cb66b2fff536 100644
--- a/drivers/mfd/altera-sysmgr.c
+++ b/drivers/mfd/altera-sysmgr.c
@@ -116,6 +116,7 @@ struct regmap *altr_sysmgr_regmap_lookup_by_phandle(struct device_node *np,
return ERR_PTR(-EPROBE_DEFER);
sysmgr = dev_get_drvdata(dev);
+ put_device(dev);
return sysmgr->regmap;
}
--
2.39.5 (Apple Git-154)
next reply other threads:[~2025-10-28 4:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-28 4:10 Miaoqian Lin [this message]
2025-11-06 16:50 ` [PATCH] mfd: altera-sysmgr: Fix device reference leak in altr_sysmgr_regmap_lookup_by_phandle Lee Jones
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=20251028041042.48874-1-linmq006@gmail.com \
--to=linmq006@gmail.com \
--cc=arnd@arndb.de \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=thor.thayer@linux.intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox