Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp165478pxx; Wed, 28 Oct 2020 01:18:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFTG1mz0/M45LBgi6VgkchRSz0qj9+oOqfko7Eo7Jcr7vMvisDycC/bA40xk7XsqSoA9bX X-Received: by 2002:a17:906:bc98:: with SMTP id lv24mr6348262ejb.536.1603873119971; Wed, 28 Oct 2020 01:18:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603873119; cv=none; d=google.com; s=arc-20160816; b=xLlt5Klc8xTOhtf1oG+XSIGb4m7Mw4hvMX2PHDMQ5BeecLqFSD2nn8YTwJjJDUYSD9 73dwhm5KCVbWwrXHQFhqKZNk3KT7hLjk5hhCWkW+OvcIEgwYIZfM4UF7v1fAf/xgPeEX VMvJwNG9hZ8sI7yqIo5hDX5Gfzuf5B6FQRpQp0pqi5Zlzdko00Pco/007dnOjPag/YRS CwD2gL/wI82CVN69quqKIXwHmicsT863SJZUrzu7Vwb00KtMlWW29lOaEj5PPwdKml6m e4iv80/rSHoPmYmgws5JQ4ZTlaXQwnUjUVnkf/gOApfOhSJVFUE0e3flikCYqnphroUn LC2w== 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=h8aOFXQgmWIn4hy/zHExK1qFX6wofQrzr9npNbNdCjI=; b=GvrdrhmNL+ufFE7fonrlFXO6KUippgG16czq++HLyaJDgZGfN8JXQNUJR5686JaXtF 3hS+iJYzjWIbSA09c2wy9h0GJDFBX+Nd6f7v+g34D1k6RvYm+NaAVl+b9M2DiG07kvZZ RZmwUCcQNRHR0zX3zpka1zEsmz3AcWZndHfa9HFbuOaYHUZUnjYT/fhBuZYSAr1LsSPc 54JSHRjpq6Rs6OZUAPtrglJ2rIjhnF/1sPWktM0hqIr0WAysOaF+MXsTa7y6LXO2WfQ0 jLem5oJd/bcH+i3GQppwhxQYGa+1PDsKdrXej6YNivufziPE1i89UIQ4ceOOIDW2thmg PGYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wfpqGQJK; 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 b6si3402013edu.343.2020.10.28.01.18.17; Wed, 28 Oct 2020 01:18:39 -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=wfpqGQJK; 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 S2438733AbgJ0OBr (ORCPT + 99 others); Tue, 27 Oct 2020 10:01:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:48560 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753598AbgJ0OA7 (ORCPT ); Tue, 27 Oct 2020 10:00:59 -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 C4BE2221F7; Tue, 27 Oct 2020 14:00:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807258; bh=JxiCFVVU2mmy1bJhcNt/vSjQkQLGKQCl1Z65CZUDOJM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wfpqGQJKhqzN8nrajW/H4xJDSPEl5o67hgKH6PlMbmH87VCm63bhyabJHIRFbsRqN WLnaHb0ZyOp5UIiI38deemNjCQTZ0WqSodjKMGMO1O8h8MhRGzZYlmIbaStSaH1Eju OijUrL9Op8qyP/8Q96GFzYaL+q44mPGfzTxk0DVc= 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.4 101/112] brcmsmac: fix memory leak in wlc_phy_attach_lcnphy Date: Tue, 27 Oct 2020 14:50:11 +0100 Message-Id: <20201027134905.321371041@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134900.532249571@linuxfoundation.org> References: <20201027134900.532249571@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 --- drivers/net/wireless/brcm80211/brcmsmac/phy/phy_lcn.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_lcn.c index 93d4cde0eb313..c9f48ec46f4a1 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_lcn.c +++ b/drivers/net/wireless/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