mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Julia Lawall <julia@diku.dk>
To: Dong Aisheng-B29396 <B29396@freescale.com>
Cc: Wolfram Sang <w.sang@pengutronix.de>, Liam Girdwood <lrg@ti.com>,
	"kernel-janitors@vger.kernel.org"
	<kernel-janitors@vger.kernel.org>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.de>,
	"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH 3/4] sound/soc/mxs/mxs-saif.c: add missing kfree
Date: Sun, 21 Aug 2011 12:57:19 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.64.1108211257040.4072@ask.diku.dk> (raw)
In-Reply-To: <65EE16ACC360FA4D99C96DC085B3F7722212DF@039-SN1MPN1-001.039d.mgd.msft.net>

On Sun, 21 Aug 2011, Dong Aisheng-B29396 wrote:

> > -----Original Message-----
> > From: Julia Lawall [mailto:julia@diku.dk]
> > Sent: Saturday, August 20, 2011 11:19 PM
> > To: Wolfram Sang
> > Cc: Liam Girdwood; kernel-janitors@vger.kernel.org; Mark Brown; Jaroslav
> > Kysela; Takashi Iwai; Dong Aisheng-B29396; alsa-devel@alsa-project.org;
> > linux-kernel@vger.kernel.org
> > Subject: Re: [PATCH 3/4] sound/soc/mxs/mxs-saif.c: add missing kfree
> > 
> > From: Julia Lawall <julia@diku.dk>
> > 
> > Move the test on pdev->id before the kzalloc to avoid requiring kfree
> > when the test fails.  This fix was suggested by Wolfram Sang.
> > 
> > A simplified version of the semantic match that finds this problem is as
> > follows: (http://coccinelle.lip6.fr/)
> > 
> > // <smpl>
> > @@
> > identifier x;
> > expression E1!=0,E2,E3,E4;
> > statement S;
> > iterator I;
> > @@
> > 
> > (
> > if (...) { ... when != kfree(x)
> >                when != x = E3
> >                when != E3 = x
> > *  return ...;
> >  }
> > ... when != x = E2
> >     when != I(...,x,...) S
> > if (...) { ... when != x = E4
> >  kfree(x); ... return ...; }
> > )
> > // </smpl>
> > 
> > Signed-off-by: Julia Lawall <julia@diku.dk>
> > 
> > ---
> > diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index
> > 0b3adae..e9a90e4 100644
> > --- a/sound/soc/mxs/mxs-saif.c
> > +++ b/sound/soc/mxs/mxs-saif.c
> > @@ -519,12 +519,11 @@ static int mxs_saif_probe(struct platform_device
> > *pdev)
> >  	struct mxs_saif *saif;
> >  	int ret = 0;
> > 
> > +	if (pdev->id >= ARRAY_SIZE(mxs_saif))
> > +		return -EINVAL;
> >  	saif = kzalloc(sizeof(*saif), GFP_KERNEL);
> >  	if (!saif)
> >  		return -ENOMEM;
> > -
> > -	if (pdev->id >= ARRAY_SIZE(mxs_saif))
> > -		return -EINVAL;
> >  	mxs_saif[pdev->id] = saif;
> > 
> >  	saif->clk = clk_get(&pdev->dev, NULL);
> 
> Thanks for the finding, Julia.
> It's ok to me.
> 
> BTW I guess you may need to resend a new version patch instead of following it
> in this mail thread. :)
> If yes, one minus thing, add one blank line below the line of 'return -ENOMEM'
> may look more comfortable.

OK, I will do both.

Thanks,
julia

  reply	other threads:[~2011-08-21 10:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-20  6:12 Julia Lawall
2011-08-20 13:44 ` Wolfram Sang
2011-08-20 15:18   ` Julia Lawall
2011-08-21 10:29     ` Dong Aisheng-B29396
2011-08-21 10:57       ` Julia Lawall [this message]
2011-08-21 11:18       ` [PATCH] " Julia Lawall
2011-08-21 11:29         ` Wolfram Sang
2011-08-21 13:40         ` Dong Aisheng-B29396
2011-08-22 10:21         ` Liam Girdwood
2011-08-22 22:35         ` Mark Brown

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=Pine.LNX.4.64.1108211257040.4072@ask.diku.dk \
    --to=julia@diku.dk \
    --cc=B29396@freescale.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@ti.com \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.de \
    --cc=w.sang@pengutronix.de \
    /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®