Skip to contentSkip to conversation

OMAP: Should cs be positive in gpmc_cs_free()?

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

Subsystems (5)
lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 OMAP: Should cs be positive in gpmc_cs_free()?

The index `cs' is signed, test whether it is negative before we release gpmc_cs_mem[cs].

---
Found by code analysis, is it required?

arch/arm/mach-omap2/gpmc.c +1 -1
index 1587682..c892a54 100644
@@ -378,7 +378,7 @@ EXPORT_SYMBOL(gpmc_cs_request);
 void gpmc_cs_free(int cs)
 {
 	spin_lock(&gpmc_mem_lock);
-	if (cs >= GPMC_CS_NUM || !gpmc_cs_reserved(cs)) {
+	if (cs >= GPMC_CS_NUM || cs < 0 || !gpmc_cs_reserved(cs)) {
 		printk(KERN_ERR "Trying to free non-reserved GPMC CS%d\n", cs);
 		BUG();
 		spin_unlock(&gpmc_mem_lock);
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Roel Kluin

The index `cs' is signed, test whether it is negative before we release gpmc_cs_mem[cs].

---
Found by code analysis, is it required?

Looks like a valid check to me.

Quoted 14 lines
arch/arm/mach-omap2/gpmc.c +1 -1
index 1587682..c892a54 100644
@@ -378,7 +378,7 @@ EXPORT_SYMBOL(gpmc_cs_request);
 void gpmc_cs_free(int cs)
 {
 	spin_lock(&gpmc_mem_lock);
-	if (cs >= GPMC_CS_NUM || !gpmc_cs_reserved(cs)) {
+	if (cs >= GPMC_CS_NUM || cs < 0 || !gpmc_cs_reserved(cs)) {
 		printk(KERN_ERR "Trying to free non-reserved GPMC CS%d\n", cs);
 		BUG();
 		spin_unlock(&gpmc_mem_lock);