Received: by 10.213.65.68 with SMTP id h4csp1682840imn; Mon, 19 Mar 2018 10:26:41 -0700 (PDT) X-Google-Smtp-Source: AG47ELsJy/Eo3MN39jpBNxoffIyMxdKWSCR2vhYtDR+xMrfJT3jECsV+fUbIqmkGtiO3UK9UsL19 X-Received: by 10.99.127.75 with SMTP id p11mr9455000pgn.392.1521480401211; Mon, 19 Mar 2018 10:26:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521480401; cv=none; d=google.com; s=arc-20160816; b=pbT3iM455xkayeP71xAB1NoByOeEscvT5gkjwenb2Zoiip4q0Y05Wks/mR3YSjs4rz RUCF5sUyxycl/xdNm7wOVyGKcI4+BqlMsYNV5M4RIdTB4cwDE+r6VqXWp7FleNnIU5zO NENfirkJuaU0gkLhy5SKql3CvnlDh2UJm2iWGNQNcYN5+8bKYVNMMqBUQLANGKhbwEBV o7TKr4i5MMMI393KASpuiCwgHnkPioksaZTcocSom5LAqeTvY0zSY5aD2XLgtWbHvu+G Hed1xJP/qwOc2OyMeEaG2HJf/7YuhVozJMJc77hL4lPZThBBotMWf0LJdli+F36A6gWf vkXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=7M4BAqxNiz0bGwGHolcupcnNJXbhgkATi2Lek6riAiA=; b=PWkt57yr4tuB4RIYJgfid1iYxMd21+NUtjal5hBlCszCBNvM12y2192ws0BOTwMTpE Jf3HmJlPT/oXKW3L7oas7xOrnund5bvZ4hK96EWsqvfanOHVoj/TcU6pK3GXsXfQLjKm tiK+9gOtqSqJPSYVfjXK9FXNuCl9ofih9y5ObuADlkYqBd+Poxh2RFxHMiEE6rUOnJih 7g8wfMYyMKOkkljLMUbhqR1sY0tXJWXdDMLvl1N7b4yQEzjv10xqOjNEaFLtc9eUY5rW Lxdu6FEmVSNhv3sfkdeYFW4OGmY17XEaetZtI7culPTMAAjUkNzD7Po88jYjRhSPe6eC rLYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=e9p5MQA0; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i3-v6si309666pli.274.2018.03.19.10.26.27; Mon, 19 Mar 2018 10:26:41 -0700 (PDT) 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=@microsoft.com header.s=selector1 header.b=e9p5MQA0; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968023AbeCSRYy (ORCPT + 99 others); Mon, 19 Mar 2018 13:24:54 -0400 Received: from mail-co1nam03on0111.outbound.protection.outlook.com ([104.47.40.111]:41411 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S966296AbeCSQI2 (ORCPT ); Mon, 19 Mar 2018 12:08:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=7M4BAqxNiz0bGwGHolcupcnNJXbhgkATi2Lek6riAiA=; b=e9p5MQA0Jm69vvi8V0Kw3/OCiBwH1s7V5UeoWgVklPFHr74SkDvbUI/Em9ST7htYn0P6X/U4M2LL3mb8DksulC6FC/zvSEVX9vUl2ltdkGeBPkVoBESfxxe7mVVRpaPAxebErFZmeYrU8OrOoJCG0GPJmmucNoaYATpsrM3U5Js= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1094.namprd21.prod.outlook.com (52.132.130.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.631.0; Mon, 19 Mar 2018 16:08:20 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62%5]) with mapi id 15.20.0631.004; Mon, 19 Mar 2018 16:08:20 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Colin Ian King , Kalle Valo , Sasha Levin Subject: [PATCH AUTOSEL for 4.4 053/167] ath5k: fix memory leak on buf on failed eeprom read Thread-Topic: [PATCH AUTOSEL for 4.4 053/167] ath5k: fix memory leak on buf on failed eeprom read Thread-Index: AQHTv5w89DE88rU+xUG5hEkknL8pbg== Date: Mon, 19 Mar 2018 16:06:26 +0000 Message-ID: <20180319160513.16384-53-alexander.levin@microsoft.com> References: <20180319160513.16384-1-alexander.levin@microsoft.com> In-Reply-To: <20180319160513.16384-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1094;7:D66cAcEja3ztF7zDaCouXpCAktiqSRlV1H6+vxJuKfITpWEruqH/+DfSHbkdme34HkJ0b3KI0sJ4w+w4t1tBetYx94U9aQM1xcN/T83XGgI48aWSWQYlksWVmDedVjjjjSolOHoszJwFFDEZN9RuBnHhMyrrLlszSli+XlcafKEOVI8LkRBjhhR9WXzg1GHDJ1fPE45FfqzQ07OvLXvrMpYW8xzw3n+nvPfp4O54J4yA79GtR+GUGZhBJaQIRkuL;20:4RZDeGVnG+bQKcKUXhqQ+vgiTyzqiK88NF+hGfxfh37mHTnEAyLu4+4CNnrRZCSLjnJMZHB0vAwWXpC6TqqXWBGrhsX31vsXdlGimaZNnFFPM3+Badj4fka8NVGX7K9DuTbW8xRfFhLuUaTKCM+CkyiF6/09kBJpn267WCI0Z6k= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 8f8e8c70-2fcd-4a1a-034f-08d58db3a238 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1094; x-ms-traffictypediagnostic: DM5PR2101MB1094: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(198206253151910); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(3231221)(944501300)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(6072148)(201708071742011);SRVR:DM5PR2101MB1094;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1094; x-forefront-prvs: 06167FAD59 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39860400002)(366004)(396003)(376002)(39380400002)(199004)(189003)(106356001)(10290500003)(110136005)(22452003)(3280700002)(478600001)(54906003)(2906002)(2900100001)(2950100002)(10090500001)(186003)(26005)(97736004)(5660300001)(72206003)(66066001)(107886003)(102836004)(53936002)(59450400001)(6506007)(6512007)(316002)(7736002)(305945005)(1076002)(6436002)(36756003)(3846002)(6116002)(6486002)(105586002)(8676002)(8936002)(86612001)(68736007)(3660700001)(86362001)(575784001)(81166006)(81156014)(25786009)(2501003)(4326008)(76176011)(5250100002)(14454004)(99286004)(22906009)(32563001)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1094;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: akNWwWUtQQjSUBPWf43a68hX79OLT/+04OL6Zz5f1JsMnxnthuUZyH7zBZe2HgCWUuXfr5GhYtJeDewyfrctx3RdmMUBJlk5TudbIk3zEkfgp/dbBtmCoEsYOrjvVwhS1NfetblzPEok/8op9Y6NEYGM62QyR5vkctkoZ0mljuigW5rGevGWYZpdm8C3fb1VyUet0iK492VjjS1SXXBfoe87dygRtXREXlLp6qAsoZJGLi/iPd2WcP7kGdeHS/4AtogOzwTGWejt+gjJK80bbM33MWCrBvfArXaRd0x2fsxDWm17MBIGUy1Wf3pohpY3E06wiFJWIqLzGKihi4vvAQ== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f8e8c70-2fcd-4a1a-034f-08d58db3a238 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Mar 2018 16:06:26.9882 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1094 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King [ Upstream commit 8fed6823e06e43ee9cf7c0ffecec2f9111ce6201 ] The AR5K_EEPROM_READ macro returns with -EIO if a read error occurs causing a memory leak on the allocated buffer buf. Fix this by explicitly calling ath5k_hw_nvram_read and exiting on the via the freebuf label that performs the necessary free'ing of buf when a read error occurs. Detected by CoverityScan, CID#1248782 ("Resource Leak") Signed-off-by: Colin Ian King Signed-off-by: Kalle Valo Signed-off-by: Sasha Levin --- drivers/net/wireless/ath/ath5k/debug.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/= ath/ath5k/debug.c index 654a1e33f827..7c5f189cace7 100644 --- a/drivers/net/wireless/ath/ath5k/debug.c +++ b/drivers/net/wireless/ath/ath5k/debug.c @@ -939,7 +939,10 @@ static int open_file_eeprom(struct inode *inode, struc= t file *file) } =20 for (i =3D 0; i < eesize; ++i) { - AR5K_EEPROM_READ(i, val); + if (!ath5k_hw_nvram_read(ah, i, &val)) { + ret =3D -EIO; + goto freebuf; + } buf[i] =3D val; } =20 --=20 2.14.1