ASoC: wm_adsp: Fix theoretical NULL pointer for alg_region
Fix potential NULL pointer dereference for alg_region in wm_adsp_buffer_parse_legacy. In practice this can never happen as loading the firmware should have failed at the wm_adsp2_setup_algs stage, however probably better for the code to be robust against future changes and this is more helpful for static analysis. Signed-off-by: Li Xu <li.xu@cirrus.com> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20191001130911.19238-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
4bb41984bf
commit
9daf4fd030
@ -3697,11 +3697,16 @@ static int wm_adsp_buffer_parse_legacy(struct wm_adsp *dsp)
|
|||||||
u32 xmalg, addr, magic;
|
u32 xmalg, addr, magic;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
|
alg_region = wm_adsp_find_alg_region(dsp, WMFW_ADSP2_XM, dsp->fw_id);
|
||||||
|
if (!alg_region) {
|
||||||
|
adsp_err(dsp, "No algorithm region found\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
buf = wm_adsp_buffer_alloc(dsp);
|
buf = wm_adsp_buffer_alloc(dsp);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
alg_region = wm_adsp_find_alg_region(dsp, WMFW_ADSP2_XM, dsp->fw_id);
|
|
||||||
xmalg = dsp->ops->sys_config_size / sizeof(__be32);
|
xmalg = dsp->ops->sys_config_size / sizeof(__be32);
|
||||||
|
|
||||||
addr = alg_region->base + xmalg + ALG_XM_FIELD(magic);
|
addr = alg_region->base + xmalg + ALG_XM_FIELD(magic);
|
||||||
|
Loading…
Reference in New Issue
Block a user