mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-18 23:09:29 +02:00
pinctrl: pinconf-generic: fix properties bitmap leak in parse_fw_cfg()
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: 9c10525510 ("pinctrl: pinconf-generic: perform basic checks on pincfg properties")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
Signed-off-by: Linus Walleij <linusw@kernel.org>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user