From: shuwang@redhat.com
To: kashyap.desai@broadcom.com, sumit.saxena@broadcom.com,
shivasharan.srikanteshwara@broadcom.com, jejb@linux.vnet.ibm.com,
martin.petersen@oracle.com
Cc: megaraidlinux.pdl@broadcom.com, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org, chuhu@redhat.com,
yizhan@redhat.com, catalin.marinas@arm.com,
Shu Wang <shuwang@redhat.com>
Subject: [PATCH V2] megaraid: kmemleak: Track page allocation for fusion
Date: Fri, 15 Sep 2017 13:21:52 +0800 [thread overview]
Message-ID: <20170915052152.5032-1-shuwang@redhat.com> (raw)
From: Shu Wang <shuwang@redhat.com>
Kmemleak reports about a thousand false positives for fusion->
cmd_list[]. Root casue is the cmd_list objects are allocated from
slab allocator, and stored its pointer in object allocated by page
allocator. The fix will tell kmemleak to track and scan fusion
object.
V2:
Add comment, balance braces, move kmemleak_free before free_pages.
checkpatch passed.
Before patch:
kmemleak: 1004 new suspected memory leaks (see /sys/kernel/debug/kmemleak)
unreferenced object 0xffff88042584e000 (size 8192):
backtrace:
kmemleak_alloc+0x4a/0xa0
__kmalloc+0xec/0x220
megasas_alloc_cmdlist_fusion+0x3e/0x140 [megaraid_sas]
megasas_alloc_cmds_fusion+0x44/0x450 [megaraid_sas]
megasas_init_adapter_fusion+0x21d/0x6e0 [megaraid_sas]
megasas_init_fw+0x357/0xd30 [megaraid_sas]
megasas_probe_one.part.34+0x5be/0x1040 [megaraid_sas]
megasas_probe_one+0x46/0xc0 [megaraid_sas]
local_pci_probe+0x45/0xa0
work_for_cpu_fn+0x14/0x20
process_one_work+0x149/0x360
worker_thread+0x1d8/0x3c0
kthread+0x109/0x140
ret_from_fork+0x25/0x30
Signed-off-by: Shu Wang <shuwang@redhat.com>
---
drivers/scsi/megaraid/megaraid_sas_fusion.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 11bd2e698b84..161b8e5518c0 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -48,6 +48,7 @@
#include <linux/mutex.h>
#include <linux/poll.h>
#include <linux/vmalloc.h>
+#include <linux/kmemleak.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
@@ -4512,6 +4513,13 @@ megasas_alloc_fusion_context(struct megasas_instance *instance)
dev_err(&instance->pdev->dev, "Failed from %s %d\n", __func__, __LINE__);
return -ENOMEM;
}
+ } else {
+ /*
+ * Allow kmemleak to scan these pages as they contain pointers
+ * to additional allocations. fusion->cmd_list[].
+ */
+ kmemleak_alloc(instance->ctrl_context,
+ sizeof(struct fusion_context), 1, GFP_KERNEL);
}
fusion = instance->ctrl_context;
@@ -4548,9 +4556,11 @@ megasas_free_fusion_context(struct megasas_instance *instance)
if (is_vmalloc_addr(fusion))
vfree(fusion);
- else
+ else {
+ kmemleak_free(fusion);
free_pages((ulong)fusion,
instance->ctrl_context_pages);
+ }
}
}
--
2.13.5
next reply other threads:[~2017-09-15 5:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-15 5:21 shuwang [this message]
2017-09-15 13:12 ` [PATCH V2] megaraid: kmemleak: Track page allocation for fusion Catalin Marinas
2017-09-15 16:16 ` Bart Van Assche
2017-09-15 18:00 ` Christoph Hellwig
2017-09-18 15:10 ` Shivasharan Srikanteshwara
2017-09-18 16:21 ` Christoph Hellwig
2017-09-25 8:08 ` Shivasharan Srikanteshwara
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=20170915052152.5032-1-shuwang@redhat.com \
--to=shuwang@redhat.com \
--cc=catalin.marinas@arm.com \
--cc=chuhu@redhat.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=kashyap.desai@broadcom.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=megaraidlinux.pdl@broadcom.com \
--cc=shivasharan.srikanteshwara@broadcom.com \
--cc=sumit.saxena@broadcom.com \
--cc=yizhan@redhat.com \
/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