public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC: 2.6.21 patch] fix sound/pci/ice1712/wtm.c:wtm_init()
@ 2007-03-19  9:24 Adrian Bunk
  2007-03-19 10:27 ` Takashi Iwai
  0 siblings, 1 reply; 3+ messages in thread
From: Adrian Bunk @ 2007-03-19  9:24 UTC (permalink / raw)
  To: Clement Guedez; +Cc: Takashi Iwai, Jaroslav Kysela, alsa-devel, linux-kernel

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

It seems what actually should be done is quite simple?

Signed-off-by: Adrian Bunk <bunk@stusta.de>

---

 sound/pci/ice1712/wtm.c |   14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

--- linux-2.6.21-rc3-mm2/sound/pci/ice1712/wtm.c.old	2007-03-19 01:29:23.000000000 +0100
+++ linux-2.6.21-rc3-mm2/sound/pci/ice1712/wtm.c	2007-03-19 01:33:06.000000000 +0100
@@ -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;
 }
 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC: 2.6.21 patch] fix sound/pci/ice1712/wtm.c:wtm_init()
  2007-03-19  9:24 [RFC: 2.6.21 patch] fix sound/pci/ice1712/wtm.c:wtm_init() Adrian Bunk
@ 2007-03-19 10:27 ` Takashi Iwai
  2007-03-19 13:08   ` Adrian Bunk
  0 siblings, 1 reply; 3+ messages in thread
From: Takashi Iwai @ 2007-03-19 10:27 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: Clement Guedez, Jaroslav Kysela, alsa-devel, linux-kernel

At Mon, 19 Mar 2007 10:24:38 +0100,
Adrian Bunk wrote:
> 
> 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...?

> 
> It seems what actually should be done is quite simple?

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


Takashi

> 
> Signed-off-by: Adrian Bunk <bunk@stusta.de>
> 
> ---
> 
>  sound/pci/ice1712/wtm.c |   14 +++-----------
>  1 file changed, 3 insertions(+), 11 deletions(-)
> 
> --- linux-2.6.21-rc3-mm2/sound/pci/ice1712/wtm.c.old	2007-03-19 01:29:23.000000000 +0100
> +++ linux-2.6.21-rc3-mm2/sound/pci/ice1712/wtm.c	2007-03-19 01:33:06.000000000 +0100
> @@ -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;
>  }
>  
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC: 2.6.21 patch] fix sound/pci/ice1712/wtm.c:wtm_init()
  2007-03-19 10:27 ` Takashi Iwai
@ 2007-03-19 13:08   ` Adrian Bunk
  0 siblings, 0 replies; 3+ messages in thread
From: Adrian Bunk @ 2007-03-19 13:08 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Clement Guedez, Jaroslav Kysela, alsa-devel, linux-kernel

On Mon, Mar 19, 2007 at 11:27:52AM +0100, Takashi Iwai wrote:
> At Mon, 19 Mar 2007 10:24:38 +0100,
> Adrian Bunk wrote:
> > 
> > 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.  :-(

> > It seems what actually should be done is quite simple?
> 
> Yes... unless someone wants to add more register initializations
> there.
> 
> 
> Takashi
> 
> > 
> > Signed-off-by: Adrian Bunk <bunk@stusta.de>
> > 
> > ---
> > 
> >  sound/pci/ice1712/wtm.c |   14 +++-----------
> >  1 file changed, 3 insertions(+), 11 deletions(-)
> > 
> > --- linux-2.6.21-rc3-mm2/sound/pci/ice1712/wtm.c.old	2007-03-19 01:29:23.000000000 +0100
> > +++ linux-2.6.21-rc3-mm2/sound/pci/ice1712/wtm.c	2007-03-19 01:33:06.000000000 +0100
> > @@ -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;
> >  }
> >  
> > 

cu
Adrian

-- 

       "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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-03-19 13:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-19  9:24 [RFC: 2.6.21 patch] fix sound/pci/ice1712/wtm.c:wtm_init() Adrian Bunk
2007-03-19 10:27 ` Takashi Iwai
2007-03-19 13:08   ` Adrian Bunk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox