Skip to contentSkip to conversation

S3C: NAND: Check the existence of nr_map before copying

PATCH New Ramax Lo 2 participants 2 messages Jan 14, 2010

Subsystems (2)
lore
Share & tools
lore

Ramax Lo

author
#0 lore raw

PATCH v2 1/1 S3C: NAND: Check the existence of nr_map before copying

Since the structure field nr_map is optional, we need to check whether the chip number map is provided to avoid unexpected NULL pointer exception.

---
 arch/arm/plat-s3c/dev-nand.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/plat-s3c/dev-nand.c +2 -2
index 84808cc..a52fb6c 100644
@@ -58,8 +58,8 @@ static int __init s3c_nand_copy_set(struct s3c2410_nand_set *set)
 			return -ENOMEM;
 	}
 	
-	size = sizeof(int) * set->nr_chips;
-	if (size) {
+	if (set->nr_map && set->nr_chips) {
+		size = sizeof(int) * set->nr_chips;
 		ptr = kmemdup(set->nr_map, size, GFP_KERNEL);
 		set->nr_map = ptr;
 
Signature · 1 line
1.5.4.3
#1 lore raw

PATCH v2 1/1 S3C: NAND: Check the existence of nr_map before copying

Quoted 2 lines · Ramax Lo

Since the structure field nr_map is optional, we need to check whether the chip number map is provided to avoid unexpected NULL pointer exception.

ok, will merge this for linus

Quoted 28 lines
---
 arch/arm/plat-s3c/dev-nand.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/plat-s3c/dev-nand.c +2 -2
index 84808cc..a52fb6c 100644
@@ -58,8 +58,8 @@ static int __init s3c_nand_copy_set(struct s3c2410_nand_set *set)
 			return -ENOMEM;
 	}
 
-	size = sizeof(int) * set->nr_chips;
-	if (size) {
+	if (set->nr_map && set->nr_chips) {
+		size = sizeof(int) * set->nr_chips;
 		ptr = kmemdup(set->nr_map, size, GFP_KERNEL);
 		set->nr_map = ptr;
 
Signature · 7 lines
1.5.4.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 5 lines
-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.