soc: qcom: fix to avoid multiple memory allocations
There is a chance that glink channel memory can be allocated multiple times if wdsp_glink_ch_info_init() is called from multiple threads. Avoid this scenario by protecting the private data structure. Change-Id: I04fc19232b0f128b36a00dc1e73a3bed03664a93 Signed-off-by: Vidyakumar Athota <vathota@codeaurora.org>
This commit is contained in:
parent
630218f710
commit
b9732c9865
1 changed files with 8 additions and 0 deletions
|
@ -531,6 +531,13 @@ static int wdsp_glink_ch_info_init(struct wdsp_glink_priv *wpriv,
|
||||||
u8 *payload;
|
u8 *payload;
|
||||||
u32 ch_size, ch_cfg_size;
|
u32 ch_size, ch_cfg_size;
|
||||||
|
|
||||||
|
mutex_lock(&wpriv->glink_mutex);
|
||||||
|
if (wpriv->ch) {
|
||||||
|
dev_err(wpriv->dev, "%s: glink ch memory is already allocated\n",
|
||||||
|
__func__);
|
||||||
|
ret = -EINVAL;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
payload = (u8 *)pkt->payload;
|
payload = (u8 *)pkt->payload;
|
||||||
no_of_channels = pkt->no_of_channels;
|
no_of_channels = pkt->no_of_channels;
|
||||||
|
|
||||||
|
@ -611,6 +618,7 @@ err_ch_mem:
|
||||||
wpriv->no_of_channels = 0;
|
wpriv->no_of_channels = 0;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
mutex_unlock(&wpriv->glink_mutex);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue