* [PATCH] drivers/macintosh: Correct potential double free
@ 2010-03-29 9:39 Julia Lawall
2010-03-29 10:57 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2010-03-29 9:39 UTC (permalink / raw)
To: Benjamin Herrenschmidt, linuxppc-dev, linux-kernel,
kernel-janitors
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/)
// <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;
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drivers/macintosh: Correct potential double free
2010-03-29 9:39 [PATCH] drivers/macintosh: Correct potential double free Julia Lawall
@ 2010-03-29 10:57 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Herrenschmidt @ 2010-03-29 10:57 UTC (permalink / raw)
To: Julia Lawall; +Cc: linuxppc-dev, kernel-janitors, linux-kernel
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;
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-03-29 10:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-29 9:39 [PATCH] drivers/macintosh: Correct potential double free Julia Lawall
2010-03-29 10:57 ` Benjamin Herrenschmidt
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).