diff mbox

[v2,2/3] ALSA: ice1712: consider error value

Message ID 1415961547-10330-2-git-send-email-sudipm.mukherjee@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sudip Mukherjee Nov. 14, 2014, 10:39 a.m. UTC
earlier we were ignoring the return value of snd_ak4114_create and
always returning 0.
now we are returning the actual status. revo_init is calling this
function, and revo_init is checking the return value.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
 sound/pci/ice1712/revo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Takashi Iwai Nov. 14, 2014, 10:43 a.m. UTC | #1
At Fri, 14 Nov 2014 16:09:06 +0530,
Sudip Mukherjee wrote:
> 
> earlier we were ignoring the return value of snd_ak4114_create and
> always returning 0.
> now we are returning the actual status. revo_init is calling this
> function, and revo_init is checking the return value.

It's not enough only to change there.  The problem is that
spec->ak4114 is dereferenced after snd_ak4114_create(), and this might
be NULL.  So it should return the error before that point.


Takashi


> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---
>  sound/pci/ice1712/revo.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/pci/ice1712/revo.c b/sound/pci/ice1712/revo.c
> index 1112ec1..2835196 100644
> --- a/sound/pci/ice1712/revo.c
> +++ b/sound/pci/ice1712/revo.c
> @@ -498,7 +498,7 @@ static int ap192_ak4114_init(struct snd_ice1712 *ice)
>  	 * No reason to stop capture stream due to incorrect checks */
>  	spec->ak4114->check_flags = AK4114_CHECK_NO_RATE;
>  
> -	return 0; /* error ignored; it's no fatal error */
> +	return err;
>  }
>  
>  static int revo_init(struct snd_ice1712 *ice)
> -- 
> 1.8.1.2
>
Sudip Mukherjee Nov. 14, 2014, 10:59 a.m. UTC | #2
On Fri, Nov 14, 2014 at 11:43:31AM +0100, Takashi Iwai wrote:
> At Fri, 14 Nov 2014 16:09:06 +0530,
> Sudip Mukherjee wrote:
> > 
> > earlier we were ignoring the return value of snd_ak4114_create and
> > always returning 0.
> > now we are returning the actual status. revo_init is calling this
> > function, and revo_init is checking the return value.
> 
> It's not enough only to change there.  The problem is that
> spec->ak4114 is dereferenced after snd_ak4114_create(), and this might
> be NULL.  So it should return the error before that point.
> 

oops .. i should have looked carefully.

one more thought:
shouldn't we also do a kfree(spec) on error ?

thanks
sudip

> 
> Takashi
> 
> 
> > Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> > ---
> >  sound/pci/ice1712/revo.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/sound/pci/ice1712/revo.c b/sound/pci/ice1712/revo.c
> > index 1112ec1..2835196 100644
> > --- a/sound/pci/ice1712/revo.c
> > +++ b/sound/pci/ice1712/revo.c
> > @@ -498,7 +498,7 @@ static int ap192_ak4114_init(struct snd_ice1712 *ice)
> >  	 * No reason to stop capture stream due to incorrect checks */
> >  	spec->ak4114->check_flags = AK4114_CHECK_NO_RATE;
> >  
> > -	return 0; /* error ignored; it's no fatal error */
> > +	return err;
> >  }
> >  
> >  static int revo_init(struct snd_ice1712 *ice)
> > -- 
> > 1.8.1.2
> >
Takashi Iwai Nov. 14, 2014, 11:03 a.m. UTC | #3
At Fri, 14 Nov 2014 16:29:15 +0530,
Sudip Mukherjee wrote:
> 
> On Fri, Nov 14, 2014 at 11:43:31AM +0100, Takashi Iwai wrote:
> > At Fri, 14 Nov 2014 16:09:06 +0530,
> > Sudip Mukherjee wrote:
> > > 
> > > earlier we were ignoring the return value of snd_ak4114_create and
> > > always returning 0.
> > > now we are returning the actual status. revo_init is calling this
> > > function, and revo_init is checking the return value.
> > 
> > It's not enough only to change there.  The problem is that
> > spec->ak4114 is dereferenced after snd_ak4114_create(), and this might
> > be NULL.  So it should return the error before that point.
> > 
> 
> oops .. i should have looked carefully.
> 
> one more thought:
> shouldn't we also do a kfree(spec) on error ?

Not necessary.  It's freed in the card's destructor.


Takashi

> 
> thanks
> sudip
> 
> > 
> > Takashi
> > 
> > 
> > > Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> > > ---
> > >  sound/pci/ice1712/revo.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/sound/pci/ice1712/revo.c b/sound/pci/ice1712/revo.c
> > > index 1112ec1..2835196 100644
> > > --- a/sound/pci/ice1712/revo.c
> > > +++ b/sound/pci/ice1712/revo.c
> > > @@ -498,7 +498,7 @@ static int ap192_ak4114_init(struct snd_ice1712 *ice)
> > >  	 * No reason to stop capture stream due to incorrect checks */
> > >  	spec->ak4114->check_flags = AK4114_CHECK_NO_RATE;
> > >  
> > > -	return 0; /* error ignored; it's no fatal error */
> > > +	return err;
> > >  }
> > >  
> > >  static int revo_init(struct snd_ice1712 *ice)
> > > -- 
> > > 1.8.1.2
> > > 
>
diff mbox

Patch

diff --git a/sound/pci/ice1712/revo.c b/sound/pci/ice1712/revo.c
index 1112ec1..2835196 100644
--- a/sound/pci/ice1712/revo.c
+++ b/sound/pci/ice1712/revo.c
@@ -498,7 +498,7 @@  static int ap192_ak4114_init(struct snd_ice1712 *ice)
 	 * No reason to stop capture stream due to incorrect checks */
 	spec->ak4114->check_flags = AK4114_CHECK_NO_RATE;
 
-	return 0; /* error ignored; it's no fatal error */
+	return err;
 }
 
 static int revo_init(struct snd_ice1712 *ice)