Skip to contentSkip to conversation

m32r: Should index be positive?

PATCH In review Roel Kluin 2 participants 2 messages Nov 1, 2009 – Nov 4, 2009

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 m32r: Should index be positive?

Index `ipi_num' is signed, test whether it is negative to make sure we don't get a negative array element.

---
 arch/m32r/kernel/smp.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Found by code analysis, is it required?

arch/m32r/kernel/smp.c +1 -1
index 8a88f1f..31cef20 100644
@@ -806,7 +806,7 @@ unsigned long send_IPI_mask_phys(cpumask_t physid_mask, int ipi_num,
 
 	if (mask & ~physids_coerce(phys_cpu_present_map))
 		BUG();
-	if (ipi_num >= NR_IPIS)
+	if (ipi_num >= NR_IPIS || ipi_num < 0)
 		BUG();
 
 	mask <<= IPI_SHIFT;
Acked-by on v1 1/1
#1 lore raw

At Sun, 01 Nov 2009 15:33:06 +0100,

Quoted 17 lines · Roel Kluin

Index `ipi_num' is signed, test whether it is negative to make sure we don't get a negative array element.

---
 arch/m32r/kernel/smp.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Found by code analysis, is it required?

arch/m32r/kernel/smp.c +0 -0
index 8a88f1f..31cef20 100644

arch/m32r/kernel/smp.c unsigned long send_IPI_mask_phys(cpumask_t physid_mask, int ipi_num, · line 812

Quoted 8 lines
arch/m32r/kernel/smp.c +1 -1
@@ -806,7 +806,7 @@ unsigned long send_IPI_mask_phys(cpumask_t physid_mask, int ipi_num,
 
 	if (mask & ~physids_coerce(phys_cpu_present_map))
 		BUG();
-	if (ipi_num >= NR_IPIS)
+	if (ipi_num >= NR_IPIS || ipi_num < 0)
 		BUG();
 
 	mask <<= IPI_SHIFT;

It looks OK for me.
I've merged this patch into my tree.

Thank you.

-- Takata