From patchwork Tue Oct 27 13:49:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 312459 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7235FC838C6 for ; Tue, 27 Oct 2020 15:47:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 48BBB22384 for ; Tue, 27 Oct 2020 15:47:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603813673; bh=XDT19sJuCogtGVxF/yvegottrr4wd6n1MDfKn62p5cc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=vZtMbtclvz5KlW/fhlhb4niX+VDefr/pVRpB4pyYszskaBAyY5EqGYmeD8A9S0ttl r5yj2M1jaHfHnCXksUHp35Q7etER7I+P0VFfpUSAE9D2kuizPkU0wLgBo4tP0XoaL4 KW0nmtsoq6uctlosIkVKYjQWJja/6HOkStKYkVmw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1802021AbgJ0PpX (ORCPT ); Tue, 27 Oct 2020 11:45:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:50112 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1799675AbgJ0Pcs (ORCPT ); Tue, 27 Oct 2020 11:32:48 -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 CB164206D4; Tue, 27 Oct 2020 15:32:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603812768; bh=XDT19sJuCogtGVxF/yvegottrr4wd6n1MDfKn62p5cc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MT0LBJ0YGGms23Ex+ifZfz/s67fEF7A7aMI4vdxV3bZNP54aszNRcSglqr0blKIAg ZQqHDuau16wYsKQM3v/kU4v64+NwgZ572VMJELySqejC3O8aRLQYkTReHoGMslfrQy F/QFurQl4UqlP9MHORZWh6eab6WS+jEHOQMufgFA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lorenzo Bianconi , Felix Fietkau , Sasha Levin Subject: [PATCH 5.9 324/757] mt76: mt7915: fix possible memory leak in mt7915_mcu_add_beacon Date: Tue, 27 Oct 2020 14:49:34 +0100 Message-Id: <20201027135505.740814350@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135450.497324313@linuxfoundation.org> References: <20201027135450.497324313@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Lorenzo Bianconi [ Upstream commit 071c8ce8e92a86b8bf78678e78eb4b79fdc16768 ] Release mcu message memory in case of failure in mt7915_mcu_add_beacon routine Fixes: e57b7901469fc ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets") Signed-off-by: Lorenzo Bianconi Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin --- .../net/wireless/mediatek/mt76/mt7915/mcu.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c index eaed5ef054016..bfd87974a5796 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c @@ -2335,14 +2335,6 @@ int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, struct bss_info_bcn *bcn; int len = MT7915_BEACON_UPDATE_SIZE + MAX_BEACON_SIZE; - rskb = mt7915_mcu_alloc_sta_req(dev, mvif, NULL, len); - if (IS_ERR(rskb)) - return PTR_ERR(rskb); - - tlv = mt7915_mcu_add_tlv(rskb, BSS_INFO_OFFLOAD, sizeof(*bcn)); - bcn = (struct bss_info_bcn *)tlv; - bcn->enable = en; - skb = ieee80211_beacon_get_template(hw, vif, &offs); if (!skb) return -EINVAL; @@ -2353,6 +2345,16 @@ int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, return -EINVAL; } + rskb = mt7915_mcu_alloc_sta_req(dev, mvif, NULL, len); + if (IS_ERR(rskb)) { + dev_kfree_skb(skb); + return PTR_ERR(rskb); + } + + tlv = mt7915_mcu_add_tlv(rskb, BSS_INFO_OFFLOAD, sizeof(*bcn)); + bcn = (struct bss_info_bcn *)tlv; + bcn->enable = en; + if (mvif->band_idx) { info = IEEE80211_SKB_CB(skb); info->hw_queue |= MT_TX_HW_QUEUE_EXT_PHY;