From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Julia Lawall <julia@diku.dk>
Cc: linuxppc-dev@ozlabs.org, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers/macintosh: Correct potential double free
Date: Mon, 29 Mar 2010 21:57:15 +1100 [thread overview]
Message-ID: <1269860235.7101.13.camel@pasglop> (raw)
In-Reply-To: <Pine.LNX.4.64.1003291138520.21896@ask.diku.dk>
On Mon, 2010-03-29 at 11:39 +0200, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
>
> The conditionals were testing different values, but then all freeing the
> same one, which could result in a double free.
>
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
Thanks. I'll stick that in my -next branch as soon as I open it :-)
Cheers,
Ben.
> // <smpl>
> @@
> expression x,e;
> identifier f;
> iterator I;
> statement S;
> @@
>
> *kfree(x);
> ... when != &x
> when != x = e
> when != I(x,...) S
> *x
> // </smpl>
>
> Signed-off-by: Julia Lawall <julia@diku.dk>
>
> ---
> drivers/macintosh/windfarm_pm91.c | 9 +++------
> 1 files changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/macintosh/windfarm_pm91.c b/drivers/macintosh/windfarm_pm91.c
> index bea9916..3442732 100644
> --- a/drivers/macintosh/windfarm_pm91.c
> +++ b/drivers/macintosh/windfarm_pm91.c
> @@ -687,12 +687,9 @@ static int __devexit wf_smu_remove(struct platform_device *ddev)
> wf_put_control(cpufreq_clamp);
>
> /* Destroy control loops state structures */
> - if (wf_smu_slots_fans)
> - kfree(wf_smu_cpu_fans);
> - if (wf_smu_drive_fans)
> - kfree(wf_smu_cpu_fans);
> - if (wf_smu_cpu_fans)
> - kfree(wf_smu_cpu_fans);
> + kfree(wf_smu_slots_fans);
> + kfree(wf_smu_drive_fans);
> + kfree(wf_smu_cpu_fans);
>
> return 0;
> }
prev parent reply other threads:[~2010-03-29 10:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-29 9:39 [PATCH] drivers/macintosh: Correct potential double free Julia Lawall
2010-03-29 10:57 ` Benjamin Herrenschmidt [this message]
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=1269860235.7101.13.camel@pasglop \
--to=benh@kernel.crashing.org \
--cc=julia@diku.dk \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
/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;
as well as URLs for NNTP newsgroup(s).