Skip to content

Commit

Permalink
ASoC: core: fix possible ZERO_SIZE_PTR pointer dereferencing error.
Browse files Browse the repository at this point in the history
Since we cannot make sure the 'params->num_regs' will always be none
zero here, and then if it equals to zero, the kmemdup() will return
ZERO_SIZE_PTR, which equals to ((void *)16).

So this patch fix this with just doing the zero check before calling
kmemdup().

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
  • Loading branch information
Xiubo Li authored and Mark Brown committed Sep 28, 2014
1 parent 7d1311b commit 6596aa0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3203,7 +3203,7 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
unsigned int val, mask;
void *data;

if (!component->regmap)
if (!component->regmap || !params->num_regs)
return -EINVAL;

len = params->num_regs * component->val_bytes;
Expand Down

0 comments on commit 6596aa0

Please sign in to comment.