aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCatalin Marinas <catalin.marinas@arm.com>2009-06-11 08:24:13 -0400
committerCatalin Marinas <catalin.marinas@arm.com>2009-06-11 12:04:18 -0400
commit2e1483c995bbd0fa6cbd055ad76088a520799ba4 (patch)
tree4b555ae3452a80e3cebd7adcab83b019d1ca1b60
parent4f2294b6dc88d99295230d97fef2c9863cec44c3 (diff)
kmemleak: Remove some of the kmemleak false positives
There are allocations for which the main pointer cannot be found but they are not memory leaks. This patch fixes some of them. For more information on false positives, see Documentation/kmemleak.txt. Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
-rw-r--r--drivers/char/vt.c7
-rw-r--r--fs/block_dev.c6
-rw-r--r--include/linux/percpu.h5
3 files changed, 18 insertions, 0 deletions
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 08151d4de489..961c1a788c61 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -104,6 +104,7 @@
104#include <linux/io.h> 104#include <linux/io.h>
105#include <asm/system.h> 105#include <asm/system.h>
106#include <linux/uaccess.h> 106#include <linux/uaccess.h>
107#include <linux/kmemleak.h>
107 108
108#define MAX_NR_CON_DRIVER 16 109#define MAX_NR_CON_DRIVER 16
109 110
@@ -2880,6 +2881,12 @@ static int __init con_init(void)
2880 */ 2881 */
2881 for (currcons = 0; currcons < MIN_NR_CONSOLES; currcons++) { 2882 for (currcons = 0; currcons < MIN_NR_CONSOLES; currcons++) {
2882 vc_cons[currcons].d = vc = alloc_bootmem(sizeof(struct vc_data)); 2883 vc_cons[currcons].d = vc = alloc_bootmem(sizeof(struct vc_data));
2884 /*
2885 * Kmemleak does not track the memory allocated via
2886 * alloc_bootmem() but this block contains pointers to
2887 * other blocks allocated via kmalloc.
2888 */
2889 kmemleak_alloc(vc, sizeof(struct vc_data), 1, GFP_ATOMIC);
2883 INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK); 2890 INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK);
2884 visual_init(vc, currcons, 1); 2891 visual_init(vc, currcons, 1);
2885 vc->vc_screenbuf = (unsigned short *)alloc_bootmem(vc->vc_screenbuf_size); 2892 vc->vc_screenbuf = (unsigned short *)alloc_bootmem(vc->vc_screenbuf_size);
diff --git a/fs/block_dev.c b/fs/block_dev.c
index f45dbc18dd17..d250f807fd83 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -25,6 +25,7 @@
25#include <linux/uio.h> 25#include <linux/uio.h>
26#include <linux/namei.h> 26#include <linux/namei.h>
27#include <linux/log2.h> 27#include <linux/log2.h>
28#include <linux/kmemleak.h>
28#include <asm/uaccess.h> 29#include <asm/uaccess.h>
29#include "internal.h" 30#include "internal.h"
30 31
@@ -492,6 +493,11 @@ void __init bdev_cache_init(void)
492 bd_mnt = kern_mount(&bd_type); 493 bd_mnt = kern_mount(&bd_type);
493 if (IS_ERR(bd_mnt)) 494 if (IS_ERR(bd_mnt))
494 panic("Cannot create bdev pseudo-fs"); 495 panic("Cannot create bdev pseudo-fs");
496 /*
497 * This vfsmount structure is only used to obtain the
498 * blockdev_superblock, so tell kmemleak not to report it.
499 */
500 kmemleak_not_leak(bd_mnt);
495 blockdev_superblock = bd_mnt->mnt_sb; /* For writeback */ 501 blockdev_superblock = bd_mnt->mnt_sb; /* For writeback */
496} 502}
497 503
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
index 1581ff235c7e..26fd9d12f050 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -86,7 +86,12 @@ struct percpu_data {
86 void *ptrs[1]; 86 void *ptrs[1];
87}; 87};
88 88
89/* pointer disguising messes up the kmemleak objects tracking */
90#ifndef CONFIG_DEBUG_KMEMLEAK
89#define __percpu_disguise(pdata) (struct percpu_data *)~(unsigned long)(pdata) 91#define __percpu_disguise(pdata) (struct percpu_data *)~(unsigned long)(pdata)
92#else
93#define __percpu_disguise(pdata) (struct percpu_data *)(pdata)
94#endif
90 95
91#define per_cpu_ptr(ptr, cpu) \ 96#define per_cpu_ptr(ptr, cpu) \
92({ \ 97({ \