ASoC: compress: fix unsigned integer overflow check

Parameter fragments and fragment_size are type of u32. U32_MAX is
the correct check.

CRs-Fixed: 1014726
Change-Id: Ia6d4755408646ac4a75724f3c6f2177651875da3
Signed-off-by: Xiaojun Sang <xsang@codeaurora.org>
This commit is contained in:
Xiaojun Sang 2016-05-24 11:16:48 +08:00 committed by L R
parent 170f5f103e
commit f5209698f0
1 changed files with 3 additions and 1 deletions

View File

@ -51,6 +51,8 @@
#define COMPR_CODEC_CAPS_OVERFLOW
#endif
#define U32_MAX ((u32)~0U)
/* TODO:
* - add substream support for multiple devices in case of
* SND_DYNAMIC_MINORS is not used
@ -505,7 +507,7 @@ static int snd_compress_check_input(struct snd_compr_params *params)
{
/* first let's check the buffer parameter's */
if (params->buffer.fragment_size == 0 ||
params->buffer.fragments > INT_MAX / params->buffer.fragment_size)
params->buffer.fragments > U32_MAX / params->buffer.fragment_size)
return -EINVAL;
/* now codec parameters */