Skip to contentSkip to conversation

mISDN: Fix memory leak in dsp_hwec_enable()

PATCH Applied Miaoqian Lin 3 participants 3 messages Aug 28, 2025 – Aug 30, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mISDN: Fix memory leak in dsp_hwec_enable()

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")
---
 drivers/isdn/mISDN/dsp_hwec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/isdn/mISDN/dsp_hwec.c +3 -3
index 0b3f29195330..0cd216e28f00 100644
@@ -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, "=");
Signature · 1 line
2.39.5 (Apple Git-154)
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Miaoqian Lin

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.

Quoted 3 lines
Fixes 9a4381618262 ("mISDN: Remove VLAs")
#2 lore raw
In reply to Miaoqian Lin
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 10 lines · 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!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html