[PATCH 8/9] mm: kmemleak: erase page->freelist in slab_destroy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



slab_destroy frees the allocated memory pointed by page->freelist. It
should also erase the reference to it. Otherwise, when the memory is
reused for another object, kmemleak will find the stale pointer and
erroneously increase the reference count of the new object. That will
lead to undetected memory leaks.

Signed-off-by: George Prekas <george@xxxxxxxxxxxxx>
---
 mm/slab.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mm/slab.c b/mm/slab.c
index aa5eb725ee9c..12acce274502 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1625,8 +1625,10 @@ static void slab_destroy(struct kmem_cache *cachep, struct slab *slab)
 	 * From now on, we don't use freelist
 	 * although actual page can be freed in rcu context
 	 */
-	if (OFF_SLAB(cachep))
+	if (OFF_SLAB(cachep)) {
 		kfree(freelist);
+		kmemleak_erase(&slab->freelist);
+	}
 }
 
 /*
-- 
2.37.1





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux