* [PATCH next] pinctrl: spacemit: fix double free of map
@ 2024-10-23 8:39 Dan Carpenter
2024-10-23 8:47 ` Yixun Lan
2024-10-28 12:54 ` Linus Walleij
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2024-10-23 8:39 UTC (permalink / raw)
To: Yixun Lan
Cc: Linus Walleij, linux-gpio, linux-kernel, kernel-janitors,
Harshit Mogalapalli
The map pointer is freed by pinctrl_utils_free_map(). It must not be a
devm_ pointer or it leads to a double free when the device is unloaded.
This is similar to a couple bugs Harshit Mogalapalli fixed earlier in
commits 3fd976afe974 ("pinctrl: nuvoton: fix a double free in
ma35_pinctrl_dt_node_to_map_func()") and 4575962aeed6 ("pinctrl: sophgo:
fix double free in cv1800_pctrl_dt_node_to_map()").
Fixes: a83c29e1d145 ("pinctrl: spacemit: add support for SpacemiT K1 SoC")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/pinctrl/spacemit/pinctrl-k1.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pinctrl/spacemit/pinctrl-k1.c b/drivers/pinctrl/spacemit/pinctrl-k1.c
index c75ea27b2344..a32579d73613 100644
--- a/drivers/pinctrl/spacemit/pinctrl-k1.c
+++ b/drivers/pinctrl/spacemit/pinctrl-k1.c
@@ -314,7 +314,7 @@ static int spacemit_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
if (!grpnames)
return -ENOMEM;
- map = devm_kcalloc(dev, ngroups * 2, sizeof(*map), GFP_KERNEL);
+ map = kcalloc(ngroups * 2, sizeof(*map), GFP_KERNEL);
if (!map)
return -ENOMEM;
--
2.45.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH next] pinctrl: spacemit: fix double free of map
2024-10-23 8:39 [PATCH next] pinctrl: spacemit: fix double free of map Dan Carpenter
@ 2024-10-23 8:47 ` Yixun Lan
2024-10-28 12:54 ` Linus Walleij
1 sibling, 0 replies; 3+ messages in thread
From: Yixun Lan @ 2024-10-23 8:47 UTC (permalink / raw)
To: Dan Carpenter
Cc: Linus Walleij, linux-gpio, linux-kernel, kernel-janitors,
Harshit Mogalapalli
On 11:39 Wed 23 Oct , Dan Carpenter wrote:
> The map pointer is freed by pinctrl_utils_free_map(). It must not be a
> devm_ pointer or it leads to a double free when the device is unloaded.
>
> This is similar to a couple bugs Harshit Mogalapalli fixed earlier in
> commits 3fd976afe974 ("pinctrl: nuvoton: fix a double free in
> ma35_pinctrl_dt_node_to_map_func()") and 4575962aeed6 ("pinctrl: sophgo:
> fix double free in cv1800_pctrl_dt_node_to_map()").
>
> Fixes: a83c29e1d145 ("pinctrl: spacemit: add support for SpacemiT K1 SoC")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Acked-by: Yixun Lan <dlan@gentoo.org>
thanks,
> ---
> drivers/pinctrl/spacemit/pinctrl-k1.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pinctrl/spacemit/pinctrl-k1.c b/drivers/pinctrl/spacemit/pinctrl-k1.c
> index c75ea27b2344..a32579d73613 100644
> --- a/drivers/pinctrl/spacemit/pinctrl-k1.c
> +++ b/drivers/pinctrl/spacemit/pinctrl-k1.c
> @@ -314,7 +314,7 @@ static int spacemit_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
> if (!grpnames)
> return -ENOMEM;
>
> - map = devm_kcalloc(dev, ngroups * 2, sizeof(*map), GFP_KERNEL);
> + map = kcalloc(ngroups * 2, sizeof(*map), GFP_KERNEL);
> if (!map)
> return -ENOMEM;
>
> --
> 2.45.2
--
Yixun Lan (dlan)
Gentoo Linux Developer
GPG Key ID AABEFD55
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH next] pinctrl: spacemit: fix double free of map
2024-10-23 8:39 [PATCH next] pinctrl: spacemit: fix double free of map Dan Carpenter
2024-10-23 8:47 ` Yixun Lan
@ 2024-10-28 12:54 ` Linus Walleij
1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2024-10-28 12:54 UTC (permalink / raw)
To: Dan Carpenter
Cc: Yixun Lan, linux-gpio, linux-kernel, kernel-janitors,
Harshit Mogalapalli
On Wed, Oct 23, 2024 at 10:39 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:
> The map pointer is freed by pinctrl_utils_free_map(). It must not be a
> devm_ pointer or it leads to a double free when the device is unloaded.
>
> This is similar to a couple bugs Harshit Mogalapalli fixed earlier in
> commits 3fd976afe974 ("pinctrl: nuvoton: fix a double free in
> ma35_pinctrl_dt_node_to_map_func()") and 4575962aeed6 ("pinctrl: sophgo:
> fix double free in cv1800_pctrl_dt_node_to_map()").
>
> Fixes: a83c29e1d145 ("pinctrl: spacemit: add support for SpacemiT K1 SoC")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Patch applied!
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-28 12:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-23 8:39 [PATCH next] pinctrl: spacemit: fix double free of map Dan Carpenter
2024-10-23 8:47 ` Yixun Lan
2024-10-28 12:54 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox