mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH 2.6.17-rc6 7/9] Remove some of the kmemleak false positives
Date: Sun, 11 Jun 2006 12:21:56 +0100	[thread overview]
Message-ID: <20060611112156.8641.94787.stgit@localhost.localdomain> (raw)
In-Reply-To: <20060611111815.8641.7879.stgit@localhost.localdomain>

From: Catalin Marinas <catalin.marinas@arm.com>

There are allocations for which the main pointer cannot be found but they
are not memory leaks. This patch fixes some of them.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
---

 arch/i386/kernel/setup.c |    1 +
 drivers/base/platform.c  |    1 +
 drivers/hwmon/w83627hf.c |    1 +
 drivers/scsi/hosts.c     |    1 +
 fs/ext3/dir.c            |    1 +
 ipc/util.c               |    2 ++
 kernel/params.c          |    7 +++++--
 mm/slab.c                |    1 +
 net/core/dev.c           |    1 +
 net/sched/sch_generic.c  |    1 +
 10 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index dd6b0e3..0866fcf 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -1323,6 +1323,7 @@ legacy_init_iomem_resources(struct resou
 		if (e820.map[i].addr + e820.map[i].size > 0x100000000ULL)
 			continue;
 		res = kzalloc(sizeof(struct resource), GFP_ATOMIC);
+		memleak_not_leak(res);
 		switch (e820.map[i].type) {
 		case E820_RAM:	res->name = "System RAM"; break;
 		case E820_ACPI:	res->name = "ACPI Tables"; break;
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 83f5c59..f818909 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -166,6 +166,7 @@ struct platform_device *platform_device_
 	struct platform_object *pa;
 
 	pa = kzalloc(sizeof(struct platform_object) + strlen(name), GFP_KERNEL);
+	memleak_padding(pa, 0, sizeof(struct platform_object));
 	if (pa) {
 		strcpy(pa->name, name);
 		pa->pdev.name = pa->name;
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index 71fb7f1..4208d37 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -1065,6 +1065,7 @@ static int w83627hf_detect(struct i2c_ad
 		err = -ENOMEM;
 		goto ERROR1;
 	}
+	memleak_container(struct w83627hf_data, client);
 
 	new_client = &data->client;
 	i2c_set_clientdata(new_client, data);
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index dfcb96f..0a05151 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -297,6 +297,7 @@ struct Scsi_Host *scsi_host_alloc(struct
 	shost = kzalloc(sizeof(struct Scsi_Host) + privsize, gfp_mask);
 	if (!shost)
 		return NULL;
+	memleak_padding(shost, 0, sizeof(struct Scsi_Host));
 
 	spin_lock_init(&shost->default_lock);
 	scsi_assign_lock(shost, &shost->default_lock);
diff --git a/fs/ext3/dir.c b/fs/ext3/dir.c
index f37528e..f66fbed 100644
--- a/fs/ext3/dir.c
+++ b/fs/ext3/dir.c
@@ -346,6 +346,7 @@ int ext3_htree_store_dirent(struct file 
 	new_fn = kmalloc(len, GFP_KERNEL);
 	if (!new_fn)
 		return -ENOMEM;
+	memleak_padding(new_fn, 0, sizeof(struct fname));
 	memset(new_fn, 0, len);
 	new_fn->hash = hash;
 	new_fn->minor_hash = minor_hash;
diff --git a/ipc/util.c b/ipc/util.c
index 8193299..dcf3e2d 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -389,6 +389,7 @@ void* ipc_rcu_alloc(int size)
 	 */
 	if (rcu_use_vmalloc(size)) {
 		out = vmalloc(HDRLEN_VMALLOC + size);
+		memleak_not_leak(out);
 		if (out) {
 			out += HDRLEN_VMALLOC;
 			container_of(out, struct ipc_rcu_hdr, data)->is_vmalloc = 1;
@@ -396,6 +397,7 @@ void* ipc_rcu_alloc(int size)
 		}
 	} else {
 		out = kmalloc(HDRLEN_KMALLOC + size, GFP_KERNEL);
+		memleak_not_leak(out);
 		if (out) {
 			out += HDRLEN_KMALLOC;
 			container_of(out, struct ipc_rcu_hdr, data)->is_vmalloc = 0;
diff --git a/kernel/params.c b/kernel/params.c
index af43ecd..a30beaf 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -548,6 +548,7 @@ static void __init kernel_param_sysfs_se
 					    unsigned int name_skip)
 {
 	struct module_kobject *mk;
+	struct module_param_attrs *mp;
 
 	mk = kzalloc(sizeof(struct module_kobject), GFP_KERNEL);
 	BUG_ON(!mk);
@@ -557,11 +558,13 @@ static void __init kernel_param_sysfs_se
 	kobject_set_name(&mk->kobj, name);
 	kobject_register(&mk->kobj);
 
+	mp = param_sysfs_setup(mk, kparam, num_params, name_skip);
 	/* no need to keep the kobject if no parameter is exported */
-	if (!param_sysfs_setup(mk, kparam, num_params, name_skip)) {
+	if (!mp) {
 		kobject_unregister(&mk->kobj);
 		kfree(mk);
-	}
+	} else
+		memleak_not_leak(mp);
 }
 
 /*
diff --git a/mm/slab.c b/mm/slab.c
index 0d38f74..395e7bb 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -3357,6 +3357,7 @@ void *__alloc_percpu(size_t size)
 		memset(pdata->ptrs[i], 0, size);
 	}
 
+	memleak_not_leak(pdata);
 	/* Catch derefs w/o wrappers */
 	return (void *)(~(unsigned long)pdata);
 
diff --git a/net/core/dev.c b/net/core/dev.c
index 4fba549..2ab745f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3103,6 +3103,7 @@ struct net_device *alloc_netdev(int size
 	dev = (struct net_device *)
 		(((long)p + NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST);
 	dev->padded = (char *)dev - (char *)p;
+	memleak_padding(p, dev->padded, sizeof(struct net_device));
 
 	if (sizeof_priv)
 		dev->priv = netdev_priv(dev);
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 138ea92..5422889 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -427,6 +427,7 @@ struct Qdisc *qdisc_alloc(struct net_dev
 	memset(p, 0, size);
 	sch = (struct Qdisc *) QDISC_ALIGN((unsigned long) p);
 	sch->padded = (char *) sch - (char *) p;
+	memleak_padding(p, sch->padded, sizeof(struct Qdisc));
 
 	INIT_LIST_HEAD(&sch->list);
 	skb_queue_head_init(&sch->q);

  parent reply	other threads:[~2006-06-11 11:22 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-11 11:18 [PATCH 2.6.17-rc6 0/9] Kernel memory leak detector 0.7 Catalin Marinas
2006-06-11 11:21 ` [PATCH 2.6.17-rc6 1/9] Base support for kmemleak Catalin Marinas
2006-06-13 11:14   ` Pekka Enberg
2006-06-13 12:47     ` Catalin Marinas
2006-06-11 11:21 ` [PATCH 2.6.17-rc6 2/9] Some documentation " Catalin Marinas
2006-06-11 11:21 ` [PATCH 2.6.17-rc6 3/9] Add the memory allocation/freeing hooks " Catalin Marinas
2006-06-11 11:21 ` [PATCH 2.6.17-rc6 4/9] Modules support " Catalin Marinas
2006-06-11 11:21 ` [PATCH 2.6.17-rc6 5/9] Add kmemleak support for i386 Catalin Marinas
2006-06-11 11:21 ` [PATCH 2.6.17-rc6 6/9] Add kmemleak support for ARM Catalin Marinas
2006-06-11 11:21 ` Catalin Marinas [this message]
2006-06-12  5:19   ` [PATCH 2.6.17-rc6 7/9] Remove some of the kmemleak false positives Pekka Enberg
2006-06-12  8:11     ` Catalin Marinas
2006-06-12  8:17       ` Pekka J Enberg
2006-06-12  8:43         ` Catalin Marinas
2006-06-12 10:53         ` Ingo Molnar
2006-06-12 11:08           ` Pekka J Enberg
2006-06-12 11:36             ` Ingo Molnar
2006-06-12 11:56               ` Pekka J Enberg
2006-06-12 12:53                 ` Catalin Marinas
2006-06-12 13:12                 ` Ingo Molnar
2006-06-12 14:38                   ` Catalin Marinas
2006-06-12 22:29                   ` Catalin Marinas
2006-06-12 12:56           ` Catalin Marinas
2006-06-12 19:22             ` Ingo Molnar
2006-06-12 22:24               ` Catalin Marinas
2006-06-13  5:53               ` Pekka J Enberg
2006-06-13  6:59                 ` Catalin Marinas
2006-06-13  7:57                   ` Pekka J Enberg
2006-06-13  9:45                     ` Catalin Marinas
2006-06-13 10:04                       ` Pekka Enberg
2006-06-13 10:37                         ` Catalin Marinas
2006-06-13  7:26                 ` Ingo Molnar
2006-06-13  8:11                   ` Pekka J Enberg
2006-06-13 10:49                   ` Catalin Marinas
2006-06-14  4:07                     ` Ingo Molnar
2006-06-14  5:46                       ` Andi Kleen
2006-06-14  5:53                       ` Jeremy Fitzhardinge
2006-06-14 12:03                         ` Ingo Molnar
2006-06-14 13:46                           ` Catalin Marinas
2006-06-14 13:35                         ` Catalin Marinas
2006-06-14 13:21                       ` Catalin Marinas
2006-06-12  9:17       ` Peter Zijlstra
2006-06-12  9:35         ` Catalin Marinas
2006-06-24 10:20     ` Catalin Marinas
2006-06-24 10:22       ` Ingo Molnar
2006-06-24 10:55         ` Catalin Marinas
2006-07-24 11:15         ` Ingo Molnar
2006-07-24 13:28           ` Catalin Marinas
2006-08-03  6:32             ` Jakub Jelinek
2006-08-03  8:31               ` Catalin Marinas
2006-06-11 11:22 ` [PATCH 2.6.17-rc6 8/9] Simple testing for kmemleak Catalin Marinas
2006-06-11 11:22 ` [PATCH 2.6.17-rc6 9/9] Keep the __init functions after initialization Catalin Marinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060611112156.8641.94787.stgit@localhost.localdomain \
    --to=catalin.marinas@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome