Skip to content

Commit c007591

Browse files
dinghaoliusmb49
authored andcommitted
ASoC: wm_adsp: fix memleak in wm_adsp_buffer_populate
BugLink: https://bugs.launchpad.net/bugs/2050858 [ 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]> Signed-off-by: Portia Stephens <[email protected]> Signed-off-by: Stefan Bader <[email protected]>
1 parent 733e098 commit c007591

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sound/soc/codecs/wm_adsp.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3766,12 +3766,12 @@ static int wm_adsp_buffer_populate(struct wm_adsp_compr_buf *buf)
37663766
ret = wm_adsp_buffer_read(buf, caps->region_defs[i].base_offset,
37673767
&region->base_addr);
37683768
if (ret < 0)
3769-
return ret;
3769+
goto err;
37703770

37713771
ret = wm_adsp_buffer_read(buf, caps->region_defs[i].size_offset,
37723772
&offset);
37733773
if (ret < 0)
3774-
return ret;
3774+
goto err;
37753775

37763776
region->cumulative_size = offset;
37773777

@@ -3782,6 +3782,10 @@ static int wm_adsp_buffer_populate(struct wm_adsp_compr_buf *buf)
37823782
}
37833783

37843784
return 0;
3785+
3786+
err:
3787+
kfree(buf->regions);
3788+
return ret;
37853789
}
37863790

37873791
static void wm_adsp_buffer_clear(struct wm_adsp_compr_buf *buf)

0 commit comments

Comments
 (0)