mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Julien Brunel <brunel@diku.dk>
Cc: perex@perex.cz, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] sound/arm: Bad NULL test
Date: Mon, 01 Sep 2008 14:12:34 +0200	[thread overview]
Message-ID: <s5hsksk12vh.wl%tiwai@suse.de> (raw)
In-Reply-To: <200809011059.54939.brunel@diku.dk>

At Mon, 1 Sep 2008 10:59:54 +0200,
Julien Brunel wrote:
> 
> From: Julien Brunel <brunel@diku.dk>
> 
> In case of error, the function aaci_init_card returns an ERR pointer,
> but never returns a NULL pointer. We have noticed a bad NULL test,
> which comes after a call to this function. Rather than doing an IS_ERR
> test, we suggest to duplicate the label out: one label for the case where
> aaci_init_card returns a valid pointer, and another for the case where
> aaci_init_card returns an ERR pointer.
> 
> The semantic match that finds this problem is as follows:
> (http://www.emn.fr/x-info/coccinelle/)
> 
> // <smpl>
> @match_bad_null_test@
> expression x, E;
> statement S1,S2;
> @@
> x =  aaci_init_card(...)
> ... when != x = E
> *  if (x != NULL) 
> S1 else S2
> // </smpl>
> 
> Signed-off-by:  Julien Brunel <brunel@diku.dk>
> Signed-off-by:  Julia Lawall <julia@diku.dk>

The fix below is simpler.  Could you check whether it's OK?

thanks,

Takashi


diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c
index b0a4744..e46b7cb 100644
--- a/sound/arm/aaci.c
+++ b/sound/arm/aaci.c
@@ -1085,6 +1085,7 @@ static int __devinit aaci_probe(struct amba_device *dev, void *id)
 	aaci = aaci_init_card(dev);
 	if (IS_ERR(aaci)) {
 		ret = PTR_ERR(aaci);
+		aaci = NULL;
 		goto out;
 	}
 

  reply	other threads:[~2008-09-01 12:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-01  8:59 Julien Brunel
2008-09-01 12:12 ` Takashi Iwai [this message]
2008-09-01 12:30   ` Julia Lawall
2008-09-01 12:43     ` Takashi Iwai
2008-09-01 13:23       ` Julia Lawall
2008-09-01 13:44         ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hsksk12vh.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=brunel@diku.dk \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®