Skip to contentSkip to conversation

Uninitialized variable in drivers/scsi/ncr53c8xx.c

PATCH In review Eric Sesterhenn 2 participants 3 messages Aug 31, 2006 – Sep 1, 2006 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Uninitialized variable in drivers/scsi/ncr53c8xx.c

hi,

this was spotted by coverity (id #880).
We use simple_strtoul() earlier to initialize pe, if the function fails, it also does not initialize it. Therefore we should initialize it ourselves, so the check in the OPT_TAGS case "if (pe && *pe == '/')" makes sense, and actually makes the command line parsing more robust.

drivers/scsi/ncr53c8xx.c renamed from drivers/scsi/ncr53c8xx.c.orig +1 -1
@@ -692,7 +692,7 @@ static int __init sym53c8xx__setup(char 
 	int xi = 0;
 
 	while (cur != NULL && (pc = strchr(cur, ':')) != NULL) {
-		char *pe;
+		char *pe = NULL;
 
 		val = 0;
 		pv = pc;
#1 lore raw
Quoted 10 lines · On Fri, 01 Sep 2006 01:29:12 +0200 Eric Sesterhenn <[email protected]> wrote:

hi,

this was spotted by coverity (id #880).
We use simple_strtoul() earlier to initialize pe, if the function fails, it also does not initialize it. Therefore we should initialize it ourselves, so the check in the OPT_TAGS case "if (pe && *pe == '/')" makes sense, and actually makes the command line parsing more robust.

simple_strtoul() always initialises `pe'.

Quoted 12 lines
drivers/scsi/ncr53c8xx.c renamed from drivers/scsi/ncr53c8xx.c.orig +1 -1
@@ -692,7 +692,7 @@ static int __init sym53c8xx__setup(char 
 	int xi = 0;
 
 	while (cur != NULL && (pc = strchr(cur, ':')) != NULL) {
-		char *pe;
+		char *pe = NULL;
 
 		val = 0;
 		pv = pc;
#2 lore raw
Quoted 12 lines · Andrew Morton
Quoted 9 lines · On Fri, 01 Sep 2006 01:29:12 +0200 Eric Sesterhenn <[email protected]> wrote:

hi,

this was spotted by coverity (id #880).
We use simple_strtoul() earlier to initialize pe, if the function fails, it also does not initialize it. Therefore we should initialize it ourselves, so the check in the OPT_TAGS case "if (pe && *pe == '/')" makes sense, and actually makes the command line parsing more robust.

Quoted 3 lines
Quoted 1 line

simple_strtoul() always initialises `pe'.

D'oh. But i think we should apply the patch nevertheless, to make the parsing code more robust, in case the command line is screwed up (and simple_strtoul() is never called).

Eric