Received: by 10.192.165.156 with SMTP id m28csp1200396imm; Wed, 11 Apr 2018 14:26:27 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+otQ16lQwdlMitgXnrcScjjUPjK8iWuo5PQo8qAp0jfmIuQ8DXXCCwRQNz96z7yDpDcBQK X-Received: by 10.101.97.130 with SMTP id c2mr4697421pgv.219.1523481986980; Wed, 11 Apr 2018 14:26:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523481986; cv=none; d=google.com; s=arc-20160816; b=GMiJz4VX2r+DnPTjsFJZiieiS+YCxD4fTJ7kyAydQUT97rdqEtLzq3RBocQHv4ScjK gGm9bav3dGJImvqGImmp/JU2wen/jK7qG2oD7hkx04AAyOWknMY6dgELvIkPE22HkyR5 h/nV7AK6ObqBOZVoy5OlxxKgR3rJ5OvEsgyqgjGBDztNDNP7KSweR4oc6bACXTzlywRd cjbFuBQIG+sWaSkDkFBYn0d2upcWNvIv92y3df8YEzketblhfQbVENue17Mn/YuKNt3k CAondd9g91GfLMYoFIrufnCQ8ZU3WcwapWh7vLjBFx/MlVFltjqWXsKeUDzBo3VCSU0E OGvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=evThJ80OnVEYGGJ+cympjDbt3ovjXqFpP23v3CKCoMA=; b=he0o1/gDmxpE4iSu55ZW5EHnDbDdlmXkorBLSBXbAc9WbQhW7EBDLhwgl+aiN2Oqg4 aHq3qKTu0eI49arQwAA714ok6NCgfm4i6ZBh0RgRkXx7CO48dTUQh8tWBu2v//qqldiA rVqc+TxhqoCcioDdC5cdoOXJPDbhcMz4HO9cSObGGojyg200h/sMbjLjrGMNO/NFpRHe zx3mgu8277Cc1aDc2kVc4YtRsNe5OPSRPtQ4Cri7n71JtBWFDh2uYrp+R461ilY5seyQ uK5Jr/NFWg5pj5CqxYyruF7gd/gaAKSNTMtpi01RnHYKF9ZiW2tJLffCe9HJPN78pI+X IrIg== ARC-Authentication-Results: i=1; mx.google.com; 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 q4si1203630pgr.515.2018.04.11.14.25.50; Wed, 11 Apr 2018 14:26:26 -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; 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 S1755190AbeDKVVv (ORCPT + 99 others); Wed, 11 Apr 2018 17:21:51 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55618 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754285AbeDKSjG (ORCPT ); Wed, 11 Apr 2018 14:39:06 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 8308DED7; Wed, 11 Apr 2018 18:39:05 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Kalle Valo , Sasha Levin Subject: [PATCH 3.18 033/121] ath5k: fix memory leak on buf on failed eeprom read Date: Wed, 11 Apr 2018 20:35:36 +0200 Message-Id: <20180411183458.093745995@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183456.195010921@linuxfoundation.org> References: <20180411183456.195010921@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/ath/ath5k/debug.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- 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 } for (i = 0; i < eesize; ++i) { - AR5K_EEPROM_READ(i, val); + if (!ath5k_hw_nvram_read(ah, i, &val)) { + ret = -EIO; + goto freebuf; + } buf[i] = val; }