mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] Eliminate double kfree
@ 2008-05-29 13:04 Julia Lawall
  2008-06-05 20:58 ` Jesse Barnes
  2008-06-05 22:32 ` Gross, Mark
  0 siblings, 2 replies; 3+ messages in thread
From: Julia Lawall @ 2008-05-29 13:04 UTC (permalink / raw)
  To: jbarnes, linux-pci, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

The destination of goto error also does a kfree(g_iommus), so it is not
correct to do one here.

This was found using the following semantic match.
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@r1@
expression E;
position p1,p2;
@@

kfree@p1(E);
...
kfree@p2(E);

@subexps@
expression E1;
position r1.p1,p;
@@

kfree@p1(<+... E1@p ...+>);

@recollect@
position subexps.p;
expression E1;
@@

E1@p

@doublekfree@
position r1.p1,r1.p2;
expression recollect.E1,E2,E;
position p;
statement S;
@@

kfree@p1(E);
<+... E1@p=E2 ...+> // the actual semantic match contains other assignments
kfree@p2(E);

@notdoublekfree@
position r1.p1,r1.p2;
position any doublekfree.p;
expression E,E1,E2;
@@

* kfree@p1(E);
... when != E1@p
    when != E1@p = E2 // needed to match a variable decl
* kfree@p2(E);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
---

diff -u -p a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
--- a/drivers/pci/intel-iommu.c	2008-05-15 18:11:35.000000000 +0200
+++ b/drivers/pci/intel-iommu.c	2008-05-24 21:20:24.000000000 +0200
@@ -1725,7 +1725,6 @@ int __init init_dmars(void)
 	deferred_flush = kzalloc(g_num_of_iommus *
 		sizeof(struct deferred_flush_tables), GFP_KERNEL);
 	if (!deferred_flush) {
-		kfree(g_iommus);
 		ret = -ENOMEM;
 		goto error;
 	}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] Eliminate double kfree
  2008-05-29 13:04 [PATCH 1/2] Eliminate double kfree Julia Lawall
@ 2008-06-05 20:58 ` Jesse Barnes
  2008-06-05 22:32 ` Gross, Mark
  1 sibling, 0 replies; 3+ messages in thread
From: Jesse Barnes @ 2008-06-05 20:58 UTC (permalink / raw)
  To: Julia Lawall; +Cc: linux-pci, linux-kernel, kernel-janitors

On Thursday, May 29, 2008 6:04 am Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
>
> The destination of goto error also does a kfree(g_iommus), so it is not
> correct to do one here.

Thanks Julia, I'll put this in linux-next.

Jesse

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH 1/2] Eliminate double kfree
  2008-05-29 13:04 [PATCH 1/2] Eliminate double kfree Julia Lawall
  2008-06-05 20:58 ` Jesse Barnes
@ 2008-06-05 22:32 ` Gross, Mark
  1 sibling, 0 replies; 3+ messages in thread
From: Gross, Mark @ 2008-06-05 22:32 UTC (permalink / raw)
  To: Julia Lawall, jbarnes, linux-pci, linux-kernel, kernel-janitors



>-----Original Message-----
>From: Julia Lawall [mailto:julia@diku.dk]
>Sent: Thursday, May 29, 2008 6:05 AM
>To: jbarnes@virtuousgeek.org; linux-pci@vger.kernel.org; linux-
>kernel@vger.kernel.org; kernel-janitors@vger.kernel.org
>Subject: [PATCH 1/2] Eliminate double kfree
>
>From: Julia Lawall <julia@diku.dk>
>
>The destination of goto error also does a kfree(g_iommus), so it is not
>correct to do one here.
>
>This was found using the following semantic match.
>(http://www.emn.fr/x-info/coccinelle/)
>
>// <smpl>
>@r1@
>expression E;
>position p1,p2;
>@@
>
>kfree@p1(E);
>...
>kfree@p2(E);
>
>@subexps@
>expression E1;
>position r1.p1,p;
>@@
>
>kfree@p1(<+... E1@p ...+>);
>
>@recollect@
>position subexps.p;
>expression E1;
>@@
>
>E1@p
>
>@doublekfree@
>position r1.p1,r1.p2;
>expression recollect.E1,E2,E;
>position p;
>statement S;
>@@
>
>kfree@p1(E);
><+... E1@p=E2 ...+> // the actual semantic match contains other
assignments
>kfree@p2(E);
>
>@notdoublekfree@
>position r1.p1,r1.p2;
>position any doublekfree.p;
>expression E,E1,E2;
>@@
>
>* kfree@p1(E);
>... when != E1@p
>    when != E1@p = E2 // needed to match a variable decl
>* kfree@p2(E);
>// </smpl>
>
>Signed-off-by: Julia Lawall <julia@diku.dk>
>---
>
>diff -u -p a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
>--- a/drivers/pci/intel-iommu.c	2008-05-15 18:11:35.000000000
+0200
>+++ b/drivers/pci/intel-iommu.c	2008-05-24 21:20:24.000000000
+0200
>@@ -1725,7 +1725,6 @@ int __init init_dmars(void)
> 	deferred_flush = kzalloc(g_num_of_iommus *
> 		sizeof(struct deferred_flush_tables), GFP_KERNEL);
> 	if (!deferred_flush) {
>-		kfree(g_iommus);
> 		ret = -ENOMEM;
> 		goto error;
> 	}
ACK.

Thanks,

--mgross

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-06-05 22:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-29 13:04 [PATCH 1/2] Eliminate double kfree Julia Lawall
2008-06-05 20:58 ` Jesse Barnes
2008-06-05 22:32 ` Gross, Mark

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®