Re: [PATCH 2/2] ASoC: Add BUG() assertion if max98095_get_bq_channelreturns -EINVAL

From: Dave Young
Date: Wed Sep 28 2011 - 21:33:18 EST


On Wed, Sep 28, 2011 at 10:02 PM, Axel Lin <axel.lin@xxxxxxxxx> wrote:
> The callers use the return value of max98095_get_bq_channel as array index to
> access max98095->dai[] array.
> Add BUG() assertion for out of bound access of max98095->dai[] array.
>
> Signed-off-by: Axel Lin <axel.lin@xxxxxxxxx>
> ---
> Âsound/soc/codecs/max98095.c | Â Â1 +
> Â1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c
> index 668434d..973c02d 100644
> --- a/sound/soc/codecs/max98095.c
> +++ b/sound/soc/codecs/max98095.c
> @@ -1998,6 +1998,7 @@ static int max98095_get_bq_channel(const char *name)
> Â Â Â Â Â Â Â Âreturn 0;
> Â Â Â Âif (strcmp(name, "Biquad2 Mode") == 0)
> Â Â Â Â Â Â Â Âreturn 1;
> + Â Â Â BUG();
> Â Â Â Âreturn -EINVAL;

below better?
BUG_ON(strcmp(name, "Biquad2 Mode"));
return 1;

Or BUG_ON(channel < 0) in caller

> Â}
>
> --
> 1.7.4.1
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at Âhttp://vger.kernel.org/majordomo-info.html
> Please read the FAQ at Âhttp://www.tux.org/lkml/
>



--
Regards
Dave
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/