Received: by 10.192.165.156 with SMTP id m28csp1138289imm; Wed, 11 Apr 2018 13:09:11 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+EqckM72ZLw4cGyLeYeI1PP/hnkeO5q6VjFCrnI63pdFBOoo3fMtkHibmqTwdJhco/Dk7w X-Received: by 2002:a17:902:bb0c:: with SMTP id l12-v6mr6410703pls.347.1523477351947; Wed, 11 Apr 2018 13:09:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523477351; cv=none; d=google.com; s=arc-20160816; b=zLX0ODirv0zBhODz6bXGrwTY/fdxfo/YEDu6v/krs2FByE5lb6PjWCc4ck1NZiv3UG h7cBTOey98TtqSlkvd6TXCLW7AZs+K97bdSDumWPz2rd4yWi+0hCp1dQusISt/HfEq1+ YcPa2umtaV8wNlwIu1xC3ChMlDTqTdcSYexqaNAmdIqH7r4W5y8USYG6qYCzOq5nNeN3 8AlFnkXi8Ey+vOfYpAtPTCB5gHFS23XmdOc5B4YitzZWZryoC48Od49fwcbeMPyDbWbr yQz6rb1JGezU1g1W3K8PrrcgDTvf6xnogJv6T2DFovYo48WikPsBUJ+VSETPuhCHhecq dPEw== 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=CsCF7gtm5V/jOEe1+rg2eV9jd2dbPab19ysfIG9oC+o=; b=r0miiRoAPvoLctHD6AZBFqUGAv/LEOCAHPeMtG8ycqrzJXDo/3sCpT/Vmxv86Yi03T QlWgS35T4qzPq18hpbbxXTbl+jrR5hscB2E/QpdwuOxhjUJ+ac/zgbjNaNXicNf+eezS mME/n+8kmy7GsDTZKIvGqA0+mtPPVexvWySMTK+ipIU7CJKybOZGqngZurrFASMa7jWb V8pvAlZ/lvrAAUgMO85c3S3HjLXdVXtM6tYqXZdijQ+WskGMICNq+WN5u95wwLnDHwyg 2vaqXL9AghhSj/vBf7YBv9tnuSEGV5d15dHOIrMPUvhcfSwxshJuspTVgFfpw4jKCKhT b69A== 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 s191si1145716pgc.824.2018.04.11.13.08.34; Wed, 11 Apr 2018 13:09:11 -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 S1756726AbeDKUDi (ORCPT + 99 others); Wed, 11 Apr 2018 16:03:38 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35646 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932437AbeDKSz7 (ORCPT ); Wed, 11 Apr 2018 14:55:59 -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 3906FC03; Wed, 11 Apr 2018 18:55:59 +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 4.9 079/310] ath5k: fix memory leak on buf on failed eeprom read Date: Wed, 11 Apr 2018 20:33:38 +0200 Message-Id: <20180411183625.696218861@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@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 4.9-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; }