diff mbox

[Resend] mtd: s3c2410: Fix potential NULL pointer dereference error

Message ID 1353062302-10266-1-git-send-email-sachin.kamat@linaro.org
State Accepted
Headers show

Commit Message

Sachin Kamat Nov. 16, 2012, 10:38 a.m. UTC
'set' is tested for NULL. But subsequently accessed without the check.
Thus making it conditional to avoid NULL pointer dereferencing.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/mtd/nand/s3c2410.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

Comments

Artem Bityutskiy Nov. 18, 2012, 10:45 a.m. UTC | #1
On Fri, 2012-11-16 at 16:08 +0530, Sachin Kamat wrote:
> 'set' is tested for NULL. But subsequently accessed without the check.
> Thus making it conditional to avoid NULL pointer dereferencing.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>

Pushed to l2-mtd.git, thanks!
diff mbox

Patch

diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
index 295e4be..bbc49c4 100644
--- a/drivers/mtd/nand/s3c2410.c
+++ b/drivers/mtd/nand/s3c2410.c
@@ -730,11 +730,14 @@  static int s3c2410_nand_add_partition(struct s3c2410_nand_info *info,
 				      struct s3c2410_nand_mtd *mtd,
 				      struct s3c2410_nand_set *set)
 {
-	if (set)
+	if (set) {
 		mtd->mtd.name = set->name;
 
-	return mtd_device_parse_register(&mtd->mtd, NULL, NULL,
+		return mtd_device_parse_register(&mtd->mtd, NULL, NULL,
 					 set->partitions, set->nr_partitions);
+	}
+
+	return -ENODEV;
 }
 
 /**