Skip to contentSkip to conversation

fix sound/pci/ice1712/wtm.c:wtm_init()

RFC PATCH In review Adrian Bunk 2 participants 4 messages Mar 19, 2007 Sound

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 fix sound/pci/ice1712/wtm.c:wtm_init()

The Coverity checker spotted this bogus for() loop that produces an array overrun.

It seems what actually should be done is quite simple?

---

 sound/pci/ice1712/wtm.c |   14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
sound/pci/ice1712/wtm.c renamed from sound/pci/ice1712/wtm.c.old +3 -11
@@ -489,23 +489,15 @@
 
 static int __devinit wtm_init(struct snd_ice1712 *ice)
 {
-	static unsigned short stac_inits_prodigy[] = {
-		STAC946X_RESET, 0,
-		(unsigned short)-1
-	};
-	unsigned short *p;
-		
 	/*WTM 192M*/
 	ice->num_total_dacs = 8;
 	ice->num_total_adcs = 4;
 	ice->force_rdma1 = 1;
 
 	/*initialize codec*/
-	p = stac_inits_prodigy;
-	for (; *p != (unsigned short)-1; p += 2) {
-		stac9460_put(ice, p[0], p[1]);
-		stac9460_2_put(ice, p[0], p[1]);
-	}
+	stac9460_put(ice, STAC946X_RESET, 0);
+	stac9460_2_put(ice, STAC946X_RESET, 0);
+
 	return 0;
 }
 

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#1 lore raw

At Mon, 19 Mar 2007 10:24:38 +0100,

Quoted 3 lines · Adrian Bunk

The Coverity checker spotted this bogus for() loop that produces an array overrun.

Hmm, I'm dense now before a caffee, but how can it overrun...?

Quoted 2 lines

It seems what actually should be done is quite simple?

Yes... unless someone wants to add more register initializations there.

Takashi

Quoted 28 lines

---

 sound/pci/ice1712/wtm.c |   14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
sound/pci/ice1712/wtm.c renamed from sound/pci/ice1712/wtm.c.old +0 -7
@@ -489,23 +489,15 @@
 
 static int __devinit wtm_init(struct snd_ice1712 *ice)
 {
-	static unsigned short stac_inits_prodigy[] = {
-		STAC946X_RESET, 0,
-		(unsigned short)-1
-	};
-	unsigned short *p;
-		
 	/*WTM 192M*/
 	ice->num_total_dacs = 8;
 	ice->num_total_adcs = 4;
 	ice->force_rdma1 = 1;
 
 	/*initialize codec*/
-	p = stac_inits_prodigy;

sound/pci/ice1712/wtm.c line 503

Quoted 10 lines
sound/pci/ice1712/wtm.c renamed from sound/pci/ice1712/wtm.c.old +3 -4
-	for (; *p != (unsigned short)-1; p += 2) {
-		stac9460_put(ice, p[0], p[1]);
-		stac9460_2_put(ice, p[0], p[1]);
-	}
+	stac9460_put(ice, STAC946X_RESET, 0);
+	stac9460_2_put(ice, STAC946X_RESET, 0);
+
 	return 0;
 }
 

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#2 lore raw
Quoted 7 lines · Takashi Iwai

At Mon, 19 Mar 2007 10:24:38 +0100,

Quoted 3 lines · Adrian Bunk

The Coverity checker spotted this bogus for() loop that produces an array overrun.

Hmm, I'm dense now before a caffee, but how can it overrun...?

Looking again, it seems I'm the one who should have drunken more tea before looking at this. :-(

Quoted 33 lines
Quoted 1 line

It seems what actually should be done is quite simple?

Yes... unless someone wants to add more register initializations there.

Takashi

Quoted 25 lines

---

 sound/pci/ice1712/wtm.c |   14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
sound/pci/ice1712/wtm.c renamed from sound/pci/ice1712/wtm.c.old +0 -6
@@ -489,23 +489,15 @@
 
 static int __devinit wtm_init(struct snd_ice1712 *ice)
 {
-	static unsigned short stac_inits_prodigy[] = {
-		STAC946X_RESET, 0,
-		(unsigned short)-1
-	};
-	unsigned short *p;
-		
 	/*WTM 192M*/
 	ice->num_total_dacs = 8;
 	ice->num_total_adcs = 4;
 	ice->force_rdma1 = 1;
 
Quoted 13 lines

sound/pci/ice1712/wtm.c line 503

Quoted 13 lines
sound/pci/ice1712/wtm.c renamed from sound/pci/ice1712/wtm.c.old +3 -5
 	/*initialize codec*/
-	p = stac_inits_prodigy;
-	for (; *p != (unsigned short)-1; p += 2) {
-		stac9460_put(ice, p[0], p[1]);
-		stac9460_2_put(ice, p[0], p[1]);
-	}
+	stac9460_put(ice, STAC946X_RESET, 0);
+	stac9460_2_put(ice, STAC946X_RESET, 0);
+
 	return 0;
 }
 

cu
Adrian

Signature · 11 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
#3 lore raw
In reply to Takashi Iwai
Quoted 7 lines · Takashi Iwai

At Mon, 19 Mar 2007 10:24:38 +0100,

Quoted 3 lines · Adrian Bunk

The Coverity checker spotted this bogus for() loop that produces an array overrun.

Hmm, I'm dense now before a caffee, but how can it overrun...?

Looking again, it seems I'm the one who should have drunken more tea before looking at this. :-(

Quoted 33 lines
Quoted 1 line

It seems what actually should be done is quite simple?

Yes... unless someone wants to add more register initializations there.

Takashi

Quoted 25 lines

---

 sound/pci/ice1712/wtm.c |   14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
sound/pci/ice1712/wtm.c renamed from sound/pci/ice1712/wtm.c.old +0 -6
@@ -489,23 +489,15 @@
 
 static int __devinit wtm_init(struct snd_ice1712 *ice)
 {
-	static unsigned short stac_inits_prodigy[] = {
-		STAC946X_RESET, 0,
-		(unsigned short)-1
-	};
-	unsigned short *p;
-		
 	/*WTM 192M*/
 	ice->num_total_dacs = 8;
 	ice->num_total_adcs = 4;
 	ice->force_rdma1 = 1;
 
Quoted 13 lines

sound/pci/ice1712/wtm.c line 503

Quoted 13 lines
sound/pci/ice1712/wtm.c renamed from sound/pci/ice1712/wtm.c.old +3 -5
 	/*initialize codec*/
-	p = stac_inits_prodigy;
-	for (; *p != (unsigned short)-1; p += 2) {
-		stac9460_put(ice, p[0], p[1]);
-		stac9460_2_put(ice, p[0], p[1]);
-	}
+	stac9460_put(ice, STAC946X_RESET, 0);
+	stac9460_2_put(ice, STAC946X_RESET, 0);
+
 	return 0;
 }
 

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed