Received: by 10.223.164.202 with SMTP id h10csp130543wrb; Thu, 9 Nov 2017 04:00:16 -0800 (PST) X-Google-Smtp-Source: ABhQp+TObm8FhZh4fhRzsAbg9mCtwew/cjD5O1xAZ/aoiTFowui75Ve2PWL/j7TBAMcqQLcvSlAP X-Received: by 10.84.128.227 with SMTP id a90mr241827pla.224.1510228815918; Thu, 09 Nov 2017 04:00:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510228815; cv=none; d=google.com; s=arc-20160816; b=mtcDwjm162+SsW5Cf1Rdv8poYMSkwskk5TgZESDArU4nabgcWSnJsPrgjdYXgMKNit 6pgKzniedGJ28sRtYuYLHm4jdUKvhXIrPzHcRtUb2E0BgIULb/Ul1yTd7Ev5xZdPk6jy knl4GBtSZnyiy7/ISP4u897FYdS9D/O6ZmHEbouKnK0We7EVvQvxxd8bGSWi4dN+iLNe htFqKsz+l9hjmLtfooLjJtRJAWzmq7DUPLPlX5FdvRfIV20MuBeiXf4qLGyw4QZqENa3 dKHFTWVgQcHR1unUU2mPhkJN/hXeUhe+NQUSKq2mDvoNmfeENEO9s+oxEcXsZihNO/Cq vT2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:message-id:date:subject:cc:to :from:dkim-signature:arc-authentication-results; bh=/tCjZCtQVQyZaA9A4LMHq4UlNef6vio48x9gX5Gwa+8=; b=Lx1igDIjWpggfOqCRPtLrnuc0ztD8pE6mJEdxZtIn0ANU3k6jkEmZfK91l+8lav6Jg Plqqh8qPTo68abGRbDgfme06RdSIfRq74ZKU2ia8/fV4G2AOkc9B4sQRJfholv2snKCM XYquC7iu0Rx1x6+J19fOm36JVSsJAmtBNahPJqD1rT49SqsdrBxipZb6cakEi5z8rLpD 1oeVmQXqB4+er3Lyz2vYYeUjPypSt6x8dVZKYigJuPat+CEXm6z/EF3VAJtF1/akoGw6 2ttLW/EMG1CchoAq7nQKDqEiVe2LVs/yUSX0GEWheznRQutvIGjhiPtwnsOPsL7C2rnS iG3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@CAVIUMNETWORKS.onmicrosoft.com header.s=selector1-cavium-com header.b=ja8/CxnR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f4si6425931plm.686.2017.11.09.04.00.03; Thu, 09 Nov 2017 04:00:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@CAVIUMNETWORKS.onmicrosoft.com header.s=selector1-cavium-com header.b=ja8/CxnR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754186AbdKIL70 (ORCPT + 81 others); Thu, 9 Nov 2017 06:59:26 -0500 Received: from mail-co1nam03on0083.outbound.protection.outlook.com ([104.47.40.83]:61792 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752459AbdKIL7X (ORCPT ); Thu, 9 Nov 2017 06:59:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=/tCjZCtQVQyZaA9A4LMHq4UlNef6vio48x9gX5Gwa+8=; b=ja8/CxnRLsXFa5CKuIS7eugkTfszG+aaXKayKKhsF64IC6P8OmJkWdytckkMTTTvdADXwQGV35NCxbgJfxwj25A2uuhRTN99cBTEprlaLZxtoJOuXP7KpFBbvHK/q4iDjX5ZZE8ZSEQcrYpEG4pQk34atbVQTIoVH5vX26Et/+A= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Aleksey.Makarov@cavium.com; Received: from localhost.localdomain (46.242.12.6) by SN2PR07MB2495.namprd07.prod.outlook.com (2603:10b6:804:6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.197.13; Thu, 9 Nov 2017 11:59:19 +0000 From: Aleksey Makarov To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, "Goutham, Sunil" , Robert Richter , Aleksey Makarov , Sunil Goutham Subject: [PATCH net-next] net: thunderx: fix double free error Date: Thu, 9 Nov 2017 14:58:57 +0300 Message-Id: <20171109115859.23838-1-aleksey.makarov@cavium.com> X-Mailer: git-send-email 2.15.0 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [46.242.12.6] X-ClientProxiedBy: AM5P194CA0014.EURP194.PROD.OUTLOOK.COM (2603:10a6:203:8f::24) To SN2PR07MB2495.namprd07.prod.outlook.com (2603:10b6:804:6::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a8e4c02e-e294-4f81-59d1-08d527695005 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603199);SRVR:SN2PR07MB2495; X-Microsoft-Exchange-Diagnostics: 1;SN2PR07MB2495;3:f468ZQj06U3QXx9LEBuJWDBQcrEfKDDze20rC8wCLSKMCa9QhFZaNDHdOqdOn+hxL8P3/riLdD/gB2FvJeQoJcGH98+HWStv9kQhnyMynRHcCVDq6DW+8N5mdSybH9Vg9tyh1m3jhFzWUQir2KPTyKUt+b1IWJSB5IDaQ5TnAPb9CS2i7QPSrny48vTr4shGKLcb54aDRmN9Itia+NfKKYr0Rw2KOfmrzG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cbgO5xXO9kPqF6ewDNNJ/45PNh70XEKnPKp6MZgi71knidG7YUqgDLxrrzilA0u2BTSxQ+PvyKm8+CzvLEMErHcNIP5li6Zv6JGDWTNHaY8AzUl6RRY;4:w1e2nDcj3loqa1tA/j/hOwvIFT8bw+0kW7dQOWnSOdojby6RBq6ddtDffbtKzGoGfUxhtrniJvViPnlp9yJLWKXbOfQr43DIsuaOFCTLRznme65hJVlhMEkDZMCs467JGRy2/xhNn8lwBZzCZ5FEPo8tn6DAFn6ZDlx60NwYNvwTjYgM5cURCWiK75Br6Kh0tsZWpHkFOWRamJnDh0UCe1UHaewmlym/xzME2uf3VsJdjM+ZfZkBsGyP2stU0Ldq+OSwkGe5hrZ0OyKFYFJyRRYuo5ZQa6rerKc+br0OHiMvsJC8UF/zeKfpuNvLMHWiT7MIOB8YmklssUg9lSOn9sPhNKJAhfrTbP/JIZGMNP0= X-Exchange-Antispam-Report-Test: UriScan:(131327999870524)(198206253151910); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(3231021)(10201501046)(3002001)(93006095)(93001095)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123564025)(20161123560025)(20161123555025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:SN2PR07MB2495;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:SN2PR07MB2495; X-Forefront-PRVS: 0486A0CB86 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(6069001)(376002)(346002)(189002)(199003)(50466002)(48376002)(53936002)(6512007)(4326008)(107886003)(86362001)(6486002)(5003940100001)(16526018)(6506006)(106356001)(2351001)(2361001)(7736002)(47776003)(66066001)(33646002)(50986999)(105586002)(101416001)(8936002)(316002)(54906003)(81166006)(81156014)(8676002)(16586007)(305945005)(25786009)(72206003)(2906002)(50226002)(478600001)(68736007)(6116002)(97736004)(3846002)(1076002)(6666003)(5660300001)(6916009)(189998001)(36756003);DIR:OUT;SFP:1101;SCL:1;SRVR:SN2PR07MB2495;H:localhost.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN2PR07MB2495;23:j0WXqZDVZXZbMZX/fuj8BfiCxfjosm78L9dUqFRF1?= =?us-ascii?Q?62wsAuSqUeBInvCVRVQaIpMslpPK3+sMgZ0arP0bsz35xFrH/IOvXOmzWtsp?= =?us-ascii?Q?vfGwLrA8s/doymNBNhoPgDUquoF9AuL1zU37xF/x1YDwSSaDWU6mlYWCrpNS?= =?us-ascii?Q?5vzzlhjrurMrULVS9C8EnY1vEMh62Nyeq7wfadv35e8VLdS98GtIvGiSdJ/7?= =?us-ascii?Q?VQTrY+Qd7Jz3hT/MycD4x5urYRLETy/Wxcnqqq35WRxRPzG7XknM1Q7co3Et?= =?us-ascii?Q?8eFaiUuHX0cykyWfjkR03sw81pXeW15HoD9cd2cKPkZc702iMhUW39pXeTXN?= =?us-ascii?Q?LlrFdQg6HKWYGLesjgn6zguRidgm2ytF7iVpBdOhc52pif1OZ8U9aFkdW1aF?= =?us-ascii?Q?gw86W9td/SIJsPmI6gzdio0mo7Aplrp7/GbgUag9Perqz2UOGo/b39evKj51?= =?us-ascii?Q?Bgck9+7x+Ji0ptBpf/PGZ9CK2ikuqcTW2/f/cJeHoWvfvo5yWASxqE7PJrYR?= =?us-ascii?Q?ppZBTp6QoSMDK+EHu1SvOWfXjpbkCytcSJ/NVD1n//eIYfa9FHjHaE7kq9g9?= =?us-ascii?Q?wKtJNwjTSxWDDKuw9Fh4tDXLK8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CS/pDdpQIETkC8Yb0kDV3M1xaIBbI/4Y79iY=;5:buGKM4JgWD5r24VhWBxnG4F2w16OoyXYy8lZhQ3NXxAVqHlO/8KkiUyBKFPTPSfDyuF3QlAINXlNN+fbwzkQYO31AUT3LxhK0fOfMsjae2H9uLl9GG1dywGw9vWKZVatMw960vjsdOwxaV4c7jKG0P0lp/V/lec1NQnaFvdzpAc=;24:Q9/E+LD5Ljy3bg0BXBzKSEsxOyAU95r68sNjedzvNiZ5MfaRWbislG4Kej7ygeIEn1aETlffHVvIyOVlGtRD6XQnSekrNvpjYJO9mtegrqM=;7:L56OBo6MBxN1ZZQtdRhhQwO64GlT0KtvLvm2S2hDkc+oihmHJg7sxdTG+Dvb1ssYlnxas4MgNfTwGEqOrnpvui68BuEofSSJEFPkBM0pMuB0uY5UokFqXuca4cNbMXnRSH4tBaFnogPpNE4mK+Qx3rS5xdoZ0m7fIwy//HVaShSiN95XVCaugU/QVQiJdoUQC7KOB6lgJj2Q4xF1oXdrfakAVAzq1nmGtbZzijp83PjjSrGTo11+TJOjibhfINPp SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2017 11:59:19.5057 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a8e4c02e-e294-4f81-59d1-08d527695005 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR07MB2495 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch fixes an error in memory allocation/freeing in ThunderX PF driver. I moved the allocation to the probe() function and made it managed. >From the Colin's email: While running static analysis on linux-next with CoverityScan I found 3 double free errors in the Cavium thunder driver. The issue occurs on the err_disable_device: label of function nic_probe when nic_free_lmacmem(nic) is called and a double free occurs on nic->duplex, nic->link and nic->speed. This occurs when nic_init_hw() fails: /* Initialize hardware */ err = nic_init_hw(nic); if (err) goto err_release_regions; nic_init_hw() calls nic_get_hw_info() and this calls nic_free_lmacmem() if any of the allocations fail. This free'ing occurs again by the call to nic_free_lmacmem() on the err_release_regions exit path in nic_probe(). Reported-by: Colin Ian King Signed-off-by: Aleksey Makarov --- drivers/net/ethernet/cavium/thunder/nic_main.c | 82 ++++++++++---------------- 1 file changed, 30 insertions(+), 52 deletions(-) diff --git a/drivers/net/ethernet/cavium/thunder/nic_main.c b/drivers/net/ethernet/cavium/thunder/nic_main.c index c12ab7f1adb9..26309e209217 100644 --- a/drivers/net/ethernet/cavium/thunder/nic_main.c +++ b/drivers/net/ethernet/cavium/thunder/nic_main.c @@ -361,17 +361,8 @@ static void nic_set_lmac_vf_mapping(struct nicpf *nic) } } -static void nic_free_lmacmem(struct nicpf *nic) +static void nic_get_hw_info(struct nicpf *nic) { - kfree(nic->vf_lmac_map); - kfree(nic->link); - kfree(nic->duplex); - kfree(nic->speed); -} - -static int nic_get_hw_info(struct nicpf *nic) -{ - u8 max_lmac; u16 sdevid; struct hw_info *hw = nic->hw; @@ -419,41 +410,16 @@ static int nic_get_hw_info(struct nicpf *nic) break; } hw->tl4_cnt = MAX_QUEUES_PER_QSET * pci_sriov_get_totalvfs(nic->pdev); - - /* Allocate memory for LMAC tracking elements */ - max_lmac = hw->bgx_cnt * MAX_LMAC_PER_BGX; - nic->vf_lmac_map = kmalloc_array(max_lmac, sizeof(u8), GFP_KERNEL); - if (!nic->vf_lmac_map) - goto error; - nic->link = kmalloc_array(max_lmac, sizeof(u8), GFP_KERNEL); - if (!nic->link) - goto error; - nic->duplex = kmalloc_array(max_lmac, sizeof(u8), GFP_KERNEL); - if (!nic->duplex) - goto error; - nic->speed = kmalloc_array(max_lmac, sizeof(u32), GFP_KERNEL); - if (!nic->speed) - goto error; - return 0; - -error: - nic_free_lmacmem(nic); - return -ENOMEM; } #define BGX0_BLOCK 8 #define BGX1_BLOCK 9 -static int nic_init_hw(struct nicpf *nic) +static void nic_init_hw(struct nicpf *nic) { - int i, err; + int i; u64 cqm_cfg; - /* Get HW capability info */ - err = nic_get_hw_info(nic); - if (err) - return err; - /* Enable NIC HW block */ nic_reg_write(nic, NIC_PF_CFG, 0x3); @@ -507,8 +473,6 @@ static int nic_init_hw(struct nicpf *nic) cqm_cfg = nic_reg_read(nic, NIC_PF_CQM_CFG); if (cqm_cfg < NICPF_CQM_MIN_DROP_LEVEL) nic_reg_write(nic, NIC_PF_CQM_CFG, NICPF_CQM_MIN_DROP_LEVEL); - - return 0; } /* Channel parse index configuration */ @@ -1325,6 +1289,7 @@ static int nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { struct device *dev = &pdev->dev; struct nicpf *nic; + u8 max_lmac; int err; BUILD_BUG_ON(sizeof(union nic_mbx) > 16); @@ -1334,10 +1299,8 @@ static int nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) return -ENOMEM; nic->hw = devm_kzalloc(dev, sizeof(struct hw_info), GFP_KERNEL); - if (!nic->hw) { - devm_kfree(dev, nic); + if (!nic->hw) return -ENOMEM; - } pci_set_drvdata(pdev, nic); @@ -1378,11 +1341,33 @@ static int nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) nic->node = nic_get_node_id(pdev); - /* Initialize hardware */ - err = nic_init_hw(nic); - if (err) + /* Get HW capability info */ + nic_get_hw_info(nic); + + /* Allocate memory for LMAC tracking elements */ + err = -ENOMEM; + max_lmac = nic->hw->bgx_cnt * MAX_LMAC_PER_BGX; + + nic->vf_lmac_map = devm_kmalloc_array(dev, max_lmac, sizeof(u8), + GFP_KERNEL); + if (!nic->vf_lmac_map) + goto err_release_regions; + + nic->link = devm_kmalloc_array(dev, max_lmac, sizeof(u8), GFP_KERNEL); + if (!nic->link) goto err_release_regions; + nic->duplex = devm_kmalloc_array(dev, max_lmac, sizeof(u8), GFP_KERNEL); + if (!nic->duplex) + goto err_release_regions; + + nic->speed = devm_kmalloc_array(dev, max_lmac, sizeof(u32), GFP_KERNEL); + if (!nic->speed) + goto err_release_regions; + + /* Initialize hardware */ + nic_init_hw(nic); + nic_set_lmac_vf_mapping(nic); /* Register interrupts */ @@ -1416,9 +1401,6 @@ static int nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err_release_regions: pci_release_regions(pdev); err_disable_device: - nic_free_lmacmem(nic); - devm_kfree(dev, nic->hw); - devm_kfree(dev, nic); pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); return err; @@ -1440,10 +1422,6 @@ static void nic_remove(struct pci_dev *pdev) nic_unregister_interrupts(nic); pci_release_regions(pdev); - nic_free_lmacmem(nic); - devm_kfree(&pdev->dev, nic->hw); - devm_kfree(&pdev->dev, nic); - pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); } -- 2.15.0 From 1584391338893338120@xxx Sat Nov 18 08:22:07 +0000 2017 X-GM-THRID: 1584391338893338120 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread