* [PATCH] mISDN: Fix memory leak in dsp_hwec_enable()
@ 2025-08-28 8:14 Miaoqian Lin
2025-08-28 19:18 ` Simon Horman
2025-08-30 2:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Miaoqian Lin @ 2025-08-28 8:14 UTC (permalink / raw)
To: Karsten Keil, Laura Abbott, David S. Miller, netdev, linux-kernel
Cc: linmq006
dsp_hwec_enable() allocates dup pointer by kstrdup(arg),
but then it updates dup variable by strsep(&dup, ",").
As a result when it calls kfree(dup), the dup variable may be
a modified pointer that no longer points to the original allocated
memory, causing a memory leak.
The issue is the same pattern as fixed in commit c6a502c22999
("mISDN: Fix memory leak in dsp_pipeline_build()").
Fixes: 9a4381618262 ("mISDN: Remove VLAs")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
drivers/isdn/mISDN/dsp_hwec.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/isdn/mISDN/dsp_hwec.c b/drivers/isdn/mISDN/dsp_hwec.c
index 0b3f29195330..0cd216e28f00 100644
--- a/drivers/isdn/mISDN/dsp_hwec.c
+++ b/drivers/isdn/mISDN/dsp_hwec.c
@@ -51,14 +51,14 @@ void dsp_hwec_enable(struct dsp *dsp, const char *arg)
goto _do;
{
- char *dup, *tok, *name, *val;
+ char *dup, *next, *tok, *name, *val;
int tmp;
- dup = kstrdup(arg, GFP_ATOMIC);
+ dup = next = kstrdup(arg, GFP_ATOMIC);
if (!dup)
return;
- while ((tok = strsep(&dup, ","))) {
+ while ((tok = strsep(&next, ","))) {
if (!strlen(tok))
continue;
name = strsep(&tok, "=");
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mISDN: Fix memory leak in dsp_hwec_enable()
2025-08-28 8:14 [PATCH] mISDN: Fix memory leak in dsp_hwec_enable() Miaoqian Lin
@ 2025-08-28 19:18 ` Simon Horman
2025-08-30 2:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2025-08-28 19:18 UTC (permalink / raw)
To: Miaoqian Lin
Cc: Karsten Keil, Laura Abbott, David S. Miller, netdev, linux-kernel
On Thu, Aug 28, 2025 at 04:14:57PM +0800, Miaoqian Lin wrote:
> dsp_hwec_enable() allocates dup pointer by kstrdup(arg),
> but then it updates dup variable by strsep(&dup, ",").
> As a result when it calls kfree(dup), the dup variable may be
> a modified pointer that no longer points to the original allocated
> memory, causing a memory leak.
>
> The issue is the same pattern as fixed in commit c6a502c22999
> ("mISDN: Fix memory leak in dsp_pipeline_build()").
Thanks for noting this, it was quite helpful to me.
>
> Fixes: 9a4381618262 ("mISDN: Remove VLAs")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mISDN: Fix memory leak in dsp_hwec_enable()
2025-08-28 8:14 [PATCH] mISDN: Fix memory leak in dsp_hwec_enable() Miaoqian Lin
2025-08-28 19:18 ` Simon Horman
@ 2025-08-30 2:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-08-30 2:30 UTC (permalink / raw)
To: Miaoqian Lin; +Cc: isdn, labbott, davem, netdev, linux-kernel
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 28 Aug 2025 16:14:57 +0800 you wrote:
> dsp_hwec_enable() allocates dup pointer by kstrdup(arg),
> but then it updates dup variable by strsep(&dup, ",").
> As a result when it calls kfree(dup), the dup variable may be
> a modified pointer that no longer points to the original allocated
> memory, causing a memory leak.
>
> The issue is the same pattern as fixed in commit c6a502c22999
> ("mISDN: Fix memory leak in dsp_pipeline_build()").
>
> [...]
Here is the summary with links:
- mISDN: Fix memory leak in dsp_hwec_enable()
https://git.kernel.org/netdev/net/c/0704a3da7ce5
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-08-30 2:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-28 8:14 [PATCH] mISDN: Fix memory leak in dsp_hwec_enable() Miaoqian Lin
2025-08-28 19:18 ` Simon Horman
2025-08-30 2:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).