Re: [PATCH] Blackfin arch: ensure index is positive

From: Mike Frysinger
Date: Mon Nov 02 2009 - 08:01:19 EST


On Mon, Nov 2, 2009 at 06:09, Roel Kluin wrote:
> The indices are signed, it's not negative before we read an
> array element.
>
> Found by code analysis, is this required?
>
> --- a/arch/blackfin/kernel/gptimers.c
> +++ b/arch/blackfin/kernel/gptimers.c
> @@ -139,7 +139,7 @@ static uint32_t const timil_mask[MAX_BLACKFIN_GPTIMERS] =
>
> Âvoid set_gptimer_pwidth(int timer_id, uint32_t value)
> Â{
> - Â Â Â tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
> + Â Â Â tassert(timer_id < MAX_BLACKFIN_GPTIMERS && timer_id >= 0);

the gptimer API is supposed to use symbolic defines only (TIMER#_id),
but that doesnt mean people couldnt pass in negative numbers
themselves. but rather than fix it this way, i'll change the API to
use unsigned ints.
-mike
--
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/