Skip to content

Commit b8668fe

Browse files
dinghaoliugregkh
authored andcommitted
ASoC: wm_adsp: fix memleak in wm_adsp_buffer_populate
[ Upstream commit 29046a7 ] When wm_adsp_buffer_read() fails, we should free buf->regions. Otherwise, the callers of wm_adsp_buffer_populate() will directly free buf on failure, which makes buf->regions a leaked memory. Fixes: a792af6 ("ASoC: wm_adsp: Refactor compress stream initialisation") Signed-off-by: Dinghao Liu <[email protected]> Reviewed-by: Richard Fitzgerald <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 0ca497a commit b8668fe

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sound/soc/codecs/wm_adsp.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -1451,12 +1451,12 @@ static int wm_adsp_buffer_populate(struct wm_adsp_compr_buf *buf)
14511451
ret = wm_adsp_buffer_read(buf, caps->region_defs[i].base_offset,
14521452
&region->base_addr);
14531453
if (ret < 0)
1454-
return ret;
1454+
goto err;
14551455

14561456
ret = wm_adsp_buffer_read(buf, caps->region_defs[i].size_offset,
14571457
&offset);
14581458
if (ret < 0)
1459-
return ret;
1459+
goto err;
14601460

14611461
region->cumulative_size = offset;
14621462

@@ -1467,6 +1467,10 @@ static int wm_adsp_buffer_populate(struct wm_adsp_compr_buf *buf)
14671467
}
14681468

14691469
return 0;
1470+
1471+
err:
1472+
kfree(buf->regions);
1473+
return ret;
14701474
}
14711475

14721476
static void wm_adsp_buffer_clear(struct wm_adsp_compr_buf *buf)

0 commit comments

Comments
 (0)