From e7061e18710741a912a7f7266ecce2345ae80ba3 Mon Sep 17 00:00:00 2001 From: Vignesh Radhakrishnan Date: Mon, 11 May 2015 16:41:54 +0530 Subject: [PATCH] smpboot: use kmemleak_not_leak for smpboot_thread_data Kmemleak reports the following memory leak : [] create_object+0x140/0x274 [] kmemleak_alloc+0x80/0xbc [] kmem_cache_alloc_trace+0x148/0x1d8 [] __smpboot_create_thread.part.2+0x2c/0xec [] smpboot_register_percpu_thread+0x90/0x118 [] spawn_ksoftirqd+0x1c/0x30 [] do_one_initcall+0xb0/0x14c [] kernel_init_freeable+0x84/0x1e0 [] kernel_init+0x10/0xcc [] ret_from_fork+0xc/0x50 This memory allocated here points to smpboot_thread_data. Data is used as an argument for this kthread. This will be used when smpboot_thread_fn runs. Therefore, is not a leak. Call kmemleak_not_leak for smpboot_thread_data pointer to ensure that kmemleak doesn't report it as a memory leak. Change-Id: I02b0a7debea3907b606856e069d63d7991b67cd9 Signed-off-by: Vignesh Radhakrishnan --- kernel/smpboot.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/smpboot.c b/kernel/smpboot.c index 7020eecb398b..bd4320479d29 100644 --- a/kernel/smpboot.c +++ b/kernel/smpboot.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "smpboot.h" @@ -174,6 +175,8 @@ __smpboot_create_thread(struct smp_hotplug_thread *ht, unsigned int cpu) td = kzalloc_node(sizeof(*td), GFP_KERNEL, cpu_to_node(cpu)); if (!td) return -ENOMEM; + + kmemleak_not_leak(td); td->cpu = cpu; td->ht = ht;