Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp181672pxx; Wed, 28 Oct 2020 01:54:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIke7EC1F61+iW2lONqFMi1YtzyxZkF95iy4Np9xAGNdN9wiSg1w9rR9UKNDwei74Bavq1 X-Received: by 2002:a17:906:d8b0:: with SMTP id qc16mr1623342ejb.268.1603875294917; Wed, 28 Oct 2020 01:54:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603875294; cv=none; d=google.com; s=arc-20160816; b=B49JTNtOHj6RyyUdPr4YTqEtmKItxxCdDpJyvkLFP96EYAe0r7DmoQAY50w8dAdEf/ 9MO59oXSTpkswGs3OOteOR5SvpbdAxpuMsfVc8l4wmvfpXMoZR43A/vfr1AUBqy9jEtw BTzH0bjb2igbyRJ0w7jIyelaoTzuRHAzT5pMiWrG26NSl/QTmy4HRXQy9NIoHDe5soH4 ezYJG43SKbkXSyGHFB8uLeLDlTI8iUjDDSNDxDIquFI/TT+a7Nv2de0iQybP6iIi4RRk jQa2o3lYqUgcVPpg2a1BPxAs88Rb6O3xC9U8VmZuPxII5+CO2mpDqjLj6caqV3SHy0lw zNdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vbH+yu9eo3fzGUFu76b/T2NicT1CazWd3dRpn5GbvYc=; b=T78Ufbosxj+u7au356Z822O78mvg8Ub+fdG2qaTC7T4zsOq/phRR0HqmbNBIoQ23no I8nqRIUTKXm4KerYyr7aPBXn5grQq6zbDfGBphxRrufWGaSEm/0ocYm53+YD+3OiWyqp 6y0RfHFJ4GPJ7sfVtFLPw1lRb6Tfb3sTZZImnw2AXtgm8+O81aH2/NnnTxyOu9iD1Rit +FTwXQPBjuKKqH3bRKHmr/THbJes6R1otmjH9zcZQxX/DfCsy3iwl9Kns4VIJrtxHjHk AaV8TVwy9fx9ZA9PwFA/XE/QMgQOWTvrJ04Q2U+IvXzynfIdca2LQ8qlowkCGLPYM6O5 xxFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Yf24KH5V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p19si2741759edu.169.2020.10.28.01.54.32; Wed, 28 Oct 2020 01:54:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Yf24KH5V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756527AbgJ0ON5 (ORCPT + 99 others); Tue, 27 Oct 2020 10:13:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:56030 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754841AbgJ0OHU (ORCPT ); Tue, 27 Oct 2020 10:07:20 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2FF2D22258; Tue, 27 Oct 2020 14:07:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807639; bh=2uPyItsYv7sh2HwsuonUm6p+JI2jQxPJkHUuWR9M74I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yf24KH5VLjD1i5zY2CGb5jUBKg+JXZ2zoQeb26RZmtugccOtsNhI3n4dipUXxs9hd 1sp+ROk4f0w72Z4uG7MoIHWmUdGoanfZEJ52cYu6puv4RaHnRz+42PYG3jTBxm9X39 L/VTYGRoVAHm9/b0KSSpabOCbHmd7FOf4aAn8nQI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Keita Suzuki , Kalle Valo , Sasha Levin Subject: [PATCH 4.9 126/139] brcmsmac: fix memory leak in wlc_phy_attach_lcnphy Date: Tue, 27 Oct 2020 14:50:20 +0100 Message-Id: <20201027134908.127325385@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134902.130312227@linuxfoundation.org> References: <20201027134902.130312227@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Keita Suzuki [ Upstream commit f4443293d741d1776b86ed1dd8c4e4285d0775fc ] When wlc_phy_txpwr_srom_read_lcnphy fails in wlc_phy_attach_lcnphy, the allocated pi->u.pi_lcnphy is leaked, since struct brcms_phy will be freed in the caller function. Fix this by calling wlc_phy_detach_lcnphy in the error handler of wlc_phy_txpwr_srom_read_lcnphy before returning. Signed-off-by: Keita Suzuki Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20200908121743.23108-1-keitasuzuki.park@sslab.ics.keio.ac.jp Signed-off-by: Sasha Levin --- .../net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c index 93d4cde0eb313..c9f48ec46f4a1 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c @@ -5090,8 +5090,10 @@ bool wlc_phy_attach_lcnphy(struct brcms_phy *pi) pi->pi_fptr.radioloftget = wlc_lcnphy_get_radio_loft; pi->pi_fptr.detach = wlc_phy_detach_lcnphy; - if (!wlc_phy_txpwr_srom_read_lcnphy(pi)) + if (!wlc_phy_txpwr_srom_read_lcnphy(pi)) { + kfree(pi->u.pi_lcnphy); return false; + } if (LCNREV_IS(pi->pubpi.phy_rev, 1)) { if (pi_lcn->lcnphy_tempsense_option == 3) { -- 2.25.1