From: Felix Gu <ustc.gu@gmail.com>
To: Linus Walleij <linusw@kernel.org>,
Conor Dooley <conor.dooley@microchip.com>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Felix Gu <ustc.gu@gmail.com>
Subject: [PATCH] pinctrl: pinconf-generic: fix properties bitmap leak in parse_fw_cfg()
Date: Mon, 20 Apr 2026 18:55:55 +0800 [thread overview]
Message-ID: <20260420-pinconf-v1-1-82f8276d8aec@gmail.com> (raw)
In parse_fw_cfg(), if fwnode_property_match_property_string() fails with
-ENOENT, the code returns directly and leaks the bitmap.
Use __free(bitmap) for automatic cleanup to fix the leak.
Fixes: 9c105255108b ("pinctrl: pinconf-generic: perform basic checks on pincfg properties")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
drivers/pinctrl/pinconf-generic.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c
index 64ed28309788..077149121628 100644
--- a/drivers/pinctrl/pinconf-generic.c
+++ b/drivers/pinctrl/pinconf-generic.c
@@ -225,10 +225,9 @@ static int parse_fw_cfg(struct fwnode_handle *fwnode,
unsigned int count, unsigned long *cfg,
unsigned int *ncfg)
{
- unsigned long *properties;
int i, test;
- properties = bitmap_zalloc(count, GFP_KERNEL);
+ unsigned long *properties __free(bitmap) = bitmap_zalloc(count, GFP_KERNEL);
for (i = 0; i < count; i++) {
u32 val;
@@ -263,7 +262,6 @@ static int parse_fw_cfg(struct fwnode_handle *fwnode,
if (ret) {
pr_err("%pfw: conflicting setting detected for %s\n",
fwnode, par->property);
- bitmap_free(properties);
return -EINVAL;
}
}
@@ -295,7 +293,6 @@ static int parse_fw_cfg(struct fwnode_handle *fwnode,
pr_err("%pfw: cannot have multiple drive configurations\n",
fwnode);
- bitmap_free(properties);
return 0;
}
---
base-commit: c7275b05bc428c7373d97aa2da02d3a7fa6b9f66
change-id: 20260420-pinconf-fe1894ac02ac
Best regards,
--
Felix Gu <ustc.gu@gmail.com>
reply other threads:[~2026-04-20 10:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260420-pinconf-v1-1-82f8276d8aec@gmail.com \
--to=ustc.gu@gmail.com \
--cc=conor.dooley@microchip.com \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox