From patchwork Thu Sep 14 12:51:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Saxena X-Patchwork-Id: 9952985 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C348B603F3 for ; Thu, 14 Sep 2017 12:51:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C07EA2839C for ; Thu, 14 Sep 2017 12:51:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B560A290C5; Thu, 14 Sep 2017 12:51:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBCE4290C4 for ; Thu, 14 Sep 2017 12:51:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751407AbdINMvV (ORCPT ); Thu, 14 Sep 2017 08:51:21 -0400 Received: from mail-io0-f180.google.com ([209.85.223.180]:53835 "EHLO mail-io0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751133AbdINMvT (ORCPT ); Thu, 14 Sep 2017 08:51:19 -0400 Received: by mail-io0-f180.google.com with SMTP id q11so49380ioe.10 for ; Thu, 14 Sep 2017 05:51:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:references:in-reply-to:mime-version:thread-index:date :message-id:subject:to:cc; bh=oW97o/WIImRqe56cuf/I71uSQ1rauREwEFSpI4a8/+k=; b=g8589ZFZq1QNt7OEyK2WV16rp5u3LoSp9YPjY3rOFoF46eB/iMxgrBA9/a9laVpap0 T+mXZSD8Rx1ojWkuyBxCiDsCYrhf/81rj944h+oUPQEssaxeeSNM8n7zUJc6zY5trEA0 NTMKeAr2U10xsRcjOqy58ZqHz5K7b73gcYW4g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:references:in-reply-to:mime-version :thread-index:date:message-id:subject:to:cc; bh=oW97o/WIImRqe56cuf/I71uSQ1rauREwEFSpI4a8/+k=; b=o7RSxClzywj7uxaGhChe7XWk5MvpPTKrruMH979lhN0yy4SkfOYJEJMaiBJxf8rKwD zQJOJtN4tu3q9ZYpBcWsKNMOPswXlyJ0ykZPPHmN31a19KygFB0mSKHlPEugKpX29Dp2 PnpprWziVLtM+Xvykqpx4/1AQN4qEVnVPRY+Zw4jwir2ZWgwMYGEdvAEgYfifevO7D4d VV5eXZFUAnx1QiK4RLTt9eBSrUQDqtNRkaFZBHnzcm1SpvIUBKjJLx4xiTgKUET9Ft4S 7YpSajAfieK7rlAN9zNgWgqcu0EROQhu6923Px0D/Z23fKtx95RokklvRRJ7Z5m4Xvgr FpKg== X-Gm-Message-State: AHPjjUiVRB0zDfmOfZ3yrazSlZfeGYZcsPK5YevUES2HtKqeHUGeYiy3 4xlP09wFh3tg6AxJKgkWbEcC1iHF3M57QIdR/quKbg== X-Google-Smtp-Source: AOwi7QC8svrcBb9NCjT0HPTUEZAGBwyPHglotnROA6+BFULxBi+tfl0hAAumYqrfVr3esIt7tzBgN7L+qOzgmr+eCMM= X-Received: by 10.202.226.13 with SMTP id z13mr25746169oig.14.1505393478822; Thu, 14 Sep 2017 05:51:18 -0700 (PDT) From: Sumit Saxena References: <20170914061646.10275-1-shuwang@redhat.com> In-Reply-To: <20170914061646.10275-1-shuwang@redhat.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQLgNHRvi7kqKoIM4lH6ImGtP6XIxKCaRv9Q Date: Thu, 14 Sep 2017 18:21:17 +0530 Message-ID: <6c64f326aac146e1c37a8efd92ce4a1d@mail.gmail.com> Subject: RE: [PATCH] megaraid: kmemleak: Track page allocation for fusion To: shuwang@redhat.com, Kashyap Desai , Shivasharan Srikanteshwara , jejb@linux.vnet.ibm.com, martin.petersen@oracle.com Cc: "PDL,MEGARAIDLINUX" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, catalin.marinas@arm.com, liwang@redhat.com, chuhu@redhat.com Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP -----Original Message----- From: shuwang@redhat.com [mailto:shuwang@redhat.com] Sent: Thursday, September 14, 2017 11:47 AM 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; catalin.marinas@arm.com; liwang@redhat.com; chuhu@redhat.com; Shu Wang Subject: [PATCH] megaraid: kmemleak: Track page allocation for fusion From: Shu Wang 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. 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 --- drivers/scsi/megaraid/megaraid_sas_fusion.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) fusion = instance->ctrl_context; @@ -4548,9 +4551,11 @@ megasas_free_fusion_context(struct megasas_instance *instance) if (is_vmalloc_addr(fusion)) vfree(fusion); - else + else { free_pages((ulong)fusion, instance->ctrl_context_pages); + kmemleak_free(fusion); + } } } Looks good. Thanks for catching this. Acked-by: Sumit Saxena -- 2.13.5 diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index 11bd2e698b84..621299edd8de 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -4512,7 +4513,9 @@ megasas_alloc_fusion_context(struct megasas_instance *instance) dev_err(&instance->pdev->dev, "Failed from %s %d\n", __func__, __LINE__); return -ENOMEM; } - } + } else + kmemleak_alloc(instance->ctrl_context, + sizeof(struct fusion_context), 1, GFP_KERNEL);