diff mbox

ASoC: wm0010: set error code on allocation failure

Message ID 20140509115538.GB32027@mwanda (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter May 9, 2014, 11:55 a.m. UTC
We should return -ENOMEM if the kzalloc() fails instead of returning
-ENOMEM.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Comments

Charles Keepax May 9, 2014, 4:18 p.m. UTC | #1
On Fri, May 09, 2014 at 02:55:38PM +0300, Dan Carpenter wrote:
> We should return -ENOMEM if the kzalloc() fails instead of returning
> -ENOMEM.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/sound/soc/codecs/wm0010.c b/sound/soc/codecs/wm0010.c
> index 71ce315..8dac6c5 100644
> --- a/sound/soc/codecs/wm0010.c
> +++ b/sound/soc/codecs/wm0010.c
> @@ -682,6 +682,7 @@ static int wm0010_boot(struct snd_soc_codec *codec)
>  		if (!img_swap) {
>  			dev_err(codec->dev,
>  				"Failed to allocate image buffer\n");
> +			ret = -ENOMEM;

No need to set this here, it is set 12 lines earlier. I agree the
current code is not the most clear, but this patch is superfluous
with the current state of the code.

Thanks,
Charles
Dan Carpenter May 9, 2014, 5:30 p.m. UTC | #2
On Fri, May 09, 2014 at 05:18:08PM +0100, Charles Keepax wrote:
> On Fri, May 09, 2014 at 02:55:38PM +0300, Dan Carpenter wrote:
> > We should return -ENOMEM if the kzalloc() fails instead of returning
> > -ENOMEM.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > 
> > diff --git a/sound/soc/codecs/wm0010.c b/sound/soc/codecs/wm0010.c
> > index 71ce315..8dac6c5 100644
> > --- a/sound/soc/codecs/wm0010.c
> > +++ b/sound/soc/codecs/wm0010.c
> > @@ -682,6 +682,7 @@ static int wm0010_boot(struct snd_soc_codec *codec)
> >  		if (!img_swap) {
> >  			dev_err(codec->dev,
> >  				"Failed to allocate image buffer\n");
> > +			ret = -ENOMEM;
> 
> No need to set this here, it is set 12 lines earlier. I agree the
> current code is not the most clear,

Oops.  That was my bad.  The code is actually totally clear, it was just
sloppiness on my part.  Sorry for that.

regards,
dan carpenter
diff mbox

Patch

diff --git a/sound/soc/codecs/wm0010.c b/sound/soc/codecs/wm0010.c
index 71ce315..8dac6c5 100644
--- a/sound/soc/codecs/wm0010.c
+++ b/sound/soc/codecs/wm0010.c
@@ -682,6 +682,7 @@  static int wm0010_boot(struct snd_soc_codec *codec)
 		if (!img_swap) {
 			dev_err(codec->dev,
 				"Failed to allocate image buffer\n");
+			ret = -ENOMEM;
 			goto abort;
 		}