Skip to contentSkip to conversation

maps: test before subtraction on unsigned long intel1size

PATCH New Roel Kluin 1 participant 1 message Mar 5, 2009 Memory technology devices (MTD)

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 maps: test before subtraction on unsigned long intel1size

I found this by code inspection, I could be wrong, but isn't a test required before this subtraction? note that intel1size is unsigned long. Also I noted that the file makes extensive use of volatile. is that necessary? ------------------------------>8-------------8<--------------------------------- Test before subtraction on unsigned long intel1size.

---

drivers/mtd/maps/nettel.c +3 -2
index a97133e..ed2fc83 100644
@@ -349,11 +349,12 @@ static int __init nettel_init(void)
 		goto out_unmap1;
 	}
 
-	intel1size = intel_mtd->size - intel0size;
-	if (intel1size > 0) {
+	if (intel_mtd->size > intel0size) {
+		intel1size = intel_mtd->size - intel0size;
 		*intel1par = SC520_PAR(intel1cs, intel1addr, intel1size);
 		__asm__ ("wbinvd");
 	} else {
+		intel1size = 0;
 		*intel1par = 0;
 	}