From: Julia Lawall <Julia.Lawall@lip6.fr>
Date: Sun, 8 Jul 2012 11:37:40 +0000 (+0200)
Subject: slub: remove invalid reference to list iterator variable
X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=068ce415bea9e2b96bde76dc1bf6e672a89903ee;p=linux.git

slub: remove invalid reference to list iterator variable

If list_for_each_entry, etc complete a traversal of the list, the iterator
variable ends up pointing to an address at an offset from the list head,
and not a meaningful structure.  Thus this value should not be used after
the end of the iterator.  The patch replaces s->name by al->name, which is
referenced nearby.

This problem was found using Coccinelle (http://coccinelle.lip6.fr/).

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
---

diff --git a/mm/slub.c b/mm/slub.c
index f96d8bcec54fb..79fe9c6b93cf8 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -5405,7 +5405,7 @@ static int __init slab_sysfs_init(void)
 		err = sysfs_slab_alias(al->s, al->name);
 		if (err)
 			printk(KERN_ERR "SLUB: Unable to add boot slab alias"
-					" %s to sysfs\n", s->name);
+					" %s to sysfs\n", al->name);
 		kfree(al);
 	}