diff --git a/asoc/msm-lsm-client.c b/asoc/msm-lsm-client.c index b688d64a06ee..aa38e8c71490 100644 --- a/asoc/msm-lsm-client.c +++ b/asoc/msm-lsm-client.c @@ -782,6 +782,13 @@ static int msm_lsm_reg_model(struct snd_pcm_substream *substream, q6lsm_sm_set_param_data(client, p_info, &offset, sm); + if ((sm->size - offset) < p_info->param_size) { + dev_err(rtd->dev, "%s: user buff size is greater than expected\n", + __func__); + rc = -EINVAL; + goto err_copy; + } + /* * For set_param, advance the sound model data with the * number of bytes required by param_data. diff --git a/asoc/msm-pcm-q6-v2.c b/asoc/msm-pcm-q6-v2.c index b26ae17520c7..bb19c4b7d386 100644 --- a/asoc/msm-pcm-q6-v2.c +++ b/asoc/msm-pcm-q6-v2.c @@ -1336,7 +1336,7 @@ static int msm_pcm_capture_copy(struct snd_pcm_substream *substream, goto fail; } - if (size == 0 || size < prtd->pcm_count) { + if ((size == 0 || size < prtd->pcm_count) && ((offset + size) < prtd->pcm_count)) { memset(bufptr + offset + size, 0, prtd->pcm_count - size); if (fbytes > prtd->pcm_count) size = xfer = prtd->pcm_count;