From patchwork Tue Jun 30 04:37:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Wang X-Patchwork-Id: 11633063 X-Patchwork-Delegate: nbd@nbd.name Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2A8913B4 for ; Tue, 30 Jun 2020 04:38:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A151620829 for ; Tue, 30 Jun 2020 04:38:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="W3zTX7af" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728523AbgF3EiC (ORCPT ); Tue, 30 Jun 2020 00:38:02 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:18903 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726710AbgF3EiC (ORCPT ); Tue, 30 Jun 2020 00:38:02 -0400 X-UUID: 3eb3c89b4f1344fc8e37c960ea0ecaa4-20200630 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=77cQOpQ5AtB0qWOQGEEMr01KtYjsozyTdiVCSYv03Yw=; b=W3zTX7afVMhUj0OQdSRSdQpfwLKLafXWrVBUiIusxocnYF+foEhz29w4t7zoOHQhP84BOV5zJT60yv9SZuNXhX/CHfENUgD6RtlcFrz43N/V8m3ySV7v/AEaanVEsYa2iPKCkRK+M4LNbMDK7Zvy7ihn7Kv6g2RA6ooFvsN5gss=; X-UUID: 3eb3c89b4f1344fc8e37c960ea0ecaa4-20200630 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 1743755523; Tue, 30 Jun 2020 12:37:58 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 30 Jun 2020 12:37:55 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 30 Jun 2020 12:37:57 +0800 From: To: , CC: , , , Subject: [PATCH 3/3] mt76: mt7615: fix potential memory leak in mcu message handler Date: Tue, 30 Jun 2020 12:37:51 +0800 Message-ID: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <5e8786d9cf0ccd09dd9c13c24c48ce441afbf0ff.1593491298.git.sean.wang@mediatek.com> References: <5e8786d9cf0ccd09dd9c13c24c48ce441afbf0ff.1593491298.git.sean.wang@mediatek.com> MIME-Version: 1.0 X-MTK: N Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Sean Wang Fix potential memory leak in mcu message handler on error condition. Fixes: 0e6a29e477f3 ("mt76: mt7615: add support to read temperature from mcu") Signed-off-by: Sean Wang Acked-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c index 1b46cccd93c5..58e3838a3dba 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c @@ -183,8 +183,10 @@ mt7615_mcu_parse_response(struct mt7615_dev *dev, int cmd, struct mt7615_mcu_rxd *rxd = (struct mt7615_mcu_rxd *)skb->data; int ret = 0; - if (seq != rxd->seq) - return -EAGAIN; + if (seq != rxd->seq) { + ret = -EAGAIN; + goto out; + } switch (cmd) { case MCU_CMD_PATCH_SEM_CONTROL: @@ -215,6 +217,7 @@ mt7615_mcu_parse_response(struct mt7615_dev *dev, int cmd, default: break; } +out: dev_kfree_skb(skb); return ret;