[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <4AEEBDD8.5080808@gmail.com>
Date: Mon, 02 Nov 2009 12:09:12 +0100
From: Roel Kluin <roel.kluin@...il.com>
To: Mike Frysinger <vapier@...too.org>,
uclinux-dist-devel@...ckfin.uclinux.org,
Andrew Morton <akpm@...ux-foundation.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH] Blackfin arch: ensure index is positive
The indices are signed, it's not negative before we read an
array element.
Signed-off-by: Roel Kluin <roel.kluin@...il.com>
---
arch/blackfin/kernel/gptimers.c | 32 ++++++++++++++++----------------
1 files changed, 16 insertions(+), 16 deletions(-)
Found by code analysis, is this required?
diff --git a/arch/blackfin/kernel/gptimers.c b/arch/blackfin/kernel/gptimers.c
index 7281a91..3b2a1c5 100644
--- 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);
timer_regs[timer_id]->width = value;
SSYNC();
}
@@ -147,14 +147,14 @@ EXPORT_SYMBOL(set_gptimer_pwidth);
uint32_t get_gptimer_pwidth(int timer_id)
{
- tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
+ tassert(timer_id < MAX_BLACKFIN_GPTIMERS && timer_id >= 0);
return timer_regs[timer_id]->width;
}
EXPORT_SYMBOL(get_gptimer_pwidth);
void set_gptimer_period(int timer_id, uint32_t period)
{
- tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
+ tassert(timer_id < MAX_BLACKFIN_GPTIMERS && timer_id >= 0);
timer_regs[timer_id]->period = period;
SSYNC();
}
@@ -162,28 +162,28 @@ EXPORT_SYMBOL(set_gptimer_period);
uint32_t get_gptimer_period(int timer_id)
{
- tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
+ tassert(timer_id < MAX_BLACKFIN_GPTIMERS && timer_id >= 0);
return timer_regs[timer_id]->period;
}
EXPORT_SYMBOL(get_gptimer_period);
uint32_t get_gptimer_count(int timer_id)
{
- tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
+ tassert(timer_id < MAX_BLACKFIN_GPTIMERS && timer_id >= 0);
return timer_regs[timer_id]->counter;
}
EXPORT_SYMBOL(get_gptimer_count);
uint32_t get_gptimer_status(int group)
{
- tassert(group < BFIN_TIMER_NUM_GROUP);
+ tassert(group < BFIN_TIMER_NUM_GROUP && group >= 0);
return group_regs[group]->status;
}
EXPORT_SYMBOL(get_gptimer_status);
void set_gptimer_status(int group, uint32_t value)
{
- tassert(group < BFIN_TIMER_NUM_GROUP);
+ tassert(group < BFIN_TIMER_NUM_GROUP && group >= 0);
group_regs[group]->status = value;
SSYNC();
}
@@ -191,42 +191,42 @@ EXPORT_SYMBOL(set_gptimer_status);
int get_gptimer_intr(int timer_id)
{
- tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
+ tassert(timer_id < MAX_BLACKFIN_GPTIMERS && timer_id >= 0);
return !!(group_regs[BFIN_TIMER_OCTET(timer_id)]->status & timil_mask[timer_id]);
}
EXPORT_SYMBOL(get_gptimer_intr);
void clear_gptimer_intr(int timer_id)
{
- tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
+ tassert(timer_id < MAX_BLACKFIN_GPTIMERS && timer_id >= 0);
group_regs[BFIN_TIMER_OCTET(timer_id)]->status = timil_mask[timer_id];
}
EXPORT_SYMBOL(clear_gptimer_intr);
int get_gptimer_over(int timer_id)
{
- tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
+ tassert(timer_id < MAX_BLACKFIN_GPTIMERS && timer_id >= 0);
return !!(group_regs[BFIN_TIMER_OCTET(timer_id)]->status & tovf_mask[timer_id]);
}
EXPORT_SYMBOL(get_gptimer_over);
void clear_gptimer_over(int timer_id)
{
- tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
+ tassert(timer_id < MAX_BLACKFIN_GPTIMERS && timer_id >= 0);
group_regs[BFIN_TIMER_OCTET(timer_id)]->status = tovf_mask[timer_id];
}
EXPORT_SYMBOL(clear_gptimer_over);
int get_gptimer_run(int timer_id)
{
- tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
+ tassert(timer_id < MAX_BLACKFIN_GPTIMERS && timer_id >= 0);
return !!(group_regs[BFIN_TIMER_OCTET(timer_id)]->status & trun_mask[timer_id]);
}
EXPORT_SYMBOL(get_gptimer_run);
void set_gptimer_config(int timer_id, uint16_t config)
{
- tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
+ tassert(timer_id < MAX_BLACKFIN_GPTIMERS && timer_id >= 0);
timer_regs[timer_id]->config = config;
SSYNC();
}
@@ -234,7 +234,7 @@ EXPORT_SYMBOL(set_gptimer_config);
uint16_t get_gptimer_config(int timer_id)
{
- tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
+ tassert(timer_id < MAX_BLACKFIN_GPTIMERS && timer_id >= 0);
return timer_regs[timer_id]->config;
}
EXPORT_SYMBOL(get_gptimer_config);
@@ -282,7 +282,7 @@ EXPORT_SYMBOL(disable_gptimers_sync);
void set_gptimer_pulse_hi(int timer_id)
{
- tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
+ tassert(timer_id < MAX_BLACKFIN_GPTIMERS && timer_id >= 0);
timer_regs[timer_id]->config |= TIMER_PULSE_HI;
SSYNC();
}
@@ -290,7 +290,7 @@ EXPORT_SYMBOL(set_gptimer_pulse_hi);
void clear_gptimer_pulse_hi(int timer_id)
{
- tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
+ tassert(timer_id < MAX_BLACKFIN_GPTIMERS && timer_id >= 0);
timer_regs[timer_id]->config &= ~TIMER_PULSE_HI;
SSYNC();
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists