public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] arch/x86/kernel/cpu/mcheck/mce_amd.c: Avoid leaving freed data in a list
@ 2011-05-13 13:52 Julia Lawall
  2011-05-15  9:36 ` [PATCH 1/3] arch/x86/kernel/cpu/mcheck/mce_amd.c: Avoid Borislav Petkov
  0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2011-05-13 13:52 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: kernel-janitors, Ingo Molnar, H. Peter Anvin, x86,
	Borislav Petkov, Robert Richter, Yinghai Lu, Andreas Herrmann,
	linux-kernel

b may be added to a list, but is not removed before being freed in the case
of an error.  This is done in the corresponding deallocation function, so
the code here has been changed to follow that.

The sematic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression E,E1,E2;
identifier l;
@@

*list_add(&E->l,E1);
... when != E1
    when != list_del(&E->l)
    when != list_del_init(&E->l)
    when != E = E2
*kfree(E);// </smpl>

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

---
 arch/x86/kernel/cpu/mcheck/mce_amd.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c
index 167f97b..bb0adad 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_amd.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c
@@ -509,6 +509,7 @@ recurse:
 out_free:
 	if (b) {
 		kobject_put(&b->kobj);
+		list_del(&b->miscj);
 		kfree(b);
 	}
 	return err;


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

end of thread, other threads:[~2011-05-15  9:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-13 13:52 [PATCH 1/3] arch/x86/kernel/cpu/mcheck/mce_amd.c: Avoid leaving freed data in a list Julia Lawall
2011-05-15  9:36 ` [PATCH 1/3] arch/x86/kernel/cpu/mcheck/mce_amd.c: Avoid Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox