From patchwork Thu Dec 13 06:49:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen-chien Jesse Sung X-Patchwork-Id: 205767 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id D09672C008A for ; Thu, 13 Dec 2012 17:52:54 +1100 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1Tj2f1-00026U-Pc; Thu, 13 Dec 2012 06:52:47 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1Tj2ew-000242-Bk for kernel-team@lists.ubuntu.com; Thu, 13 Dec 2012 06:52:42 +0000 Received: from [112.104.135.12] (helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1Tj2dR-0000NG-OM; Thu, 13 Dec 2012 06:51:10 +0000 From: Jesse Sung To: kernel-team@lists.ubuntu.com Subject: [Quantal][PATCH 25/29] be2net: fixup malloc/free of adapter->pmac_id Date: Thu, 13 Dec 2012 14:49:58 +0800 Message-Id: <1355381402-10497-25-git-send-email-jesse.sung@canonical.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1355381402-10497-1-git-send-email-jesse.sung@canonical.com> References: <1355381402-10497-1-git-send-email-jesse.sung@canonical.com> Cc: Sathya Perla , Sarveshwar Bandi X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com From: Sathya Perla BugLink: https://launchpad.net/bugs/1083088 Free was missing and kcalloc() is better placed in be_ctrl_init() Signed-off-by: Sathya Perla Signed-off-by: David S. Miller (cherry picked from commit cc7d723adb7778e4eff8956f2d137c0729b9a81e) Signed-off-by: Wen-chien Jesse Sung --- drivers/net/ethernet/emulex/benet/be_main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 0ae1e9c..6c2ff94 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -3436,6 +3436,7 @@ static void be_ctrl_cleanup(struct be_adapter *adapter) if (mem->va) dma_free_coherent(&adapter->pdev->dev, mem->size, mem->va, mem->dma); + kfree(adapter->pmac_id); } static int be_ctrl_init(struct be_adapter *adapter) @@ -3472,6 +3473,12 @@ static int be_ctrl_init(struct be_adapter *adapter) } memset(rx_filter->va, 0, rx_filter->size); + /* primary mac needs 1 pmac entry */ + adapter->pmac_id = kcalloc(adapter->max_pmac_cnt + 1, + sizeof(*adapter->pmac_id), GFP_KERNEL); + if (!adapter->pmac_id) + return -ENOMEM; + mutex_init(&adapter->mbox_lock); spin_lock_init(&adapter->mcc_lock); spin_lock_init(&adapter->mcc_cq_lock); @@ -3608,12 +3615,6 @@ static int be_get_initial_config(struct be_adapter *adapter) else adapter->max_pmac_cnt = BE_VF_UC_PMAC_COUNT; - /* primary mac needs 1 pmac entry */ - adapter->pmac_id = kcalloc(adapter->max_pmac_cnt + 1, - sizeof(u32), GFP_KERNEL); - if (!adapter->pmac_id) - return -ENOMEM; - status = be_cmd_get_cntl_attributes(adapter); if (status) return status;