From patchwork Tue Jul 7 19:16:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Wang X-Patchwork-Id: 11649853 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 D238192A for ; Tue, 7 Jul 2020 19:17:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA8BE2075B for ; Tue, 7 Jul 2020 19:17:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="XVo/B7sn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728866AbgGGTRB (ORCPT ); Tue, 7 Jul 2020 15:17:01 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:40254 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728858AbgGGTRB (ORCPT ); Tue, 7 Jul 2020 15:17:01 -0400 X-UUID: f330164182ec492bb7d2d01260bf9607-20200708 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:Message-ID:Date:Subject:CC:To:From; bh=2sll/Y485e+JNsrlD/BIKIwTJsEpJPT8Kwje84O+F/g=; b=XVo/B7sna3yn2Bnjv2ZnEAx+SuxoQHSNUJVBLUynozxX0xfyiIvpcQM6XP9lJGzwrAZ+6s+pgwbgTbj8q6X/0Uz99AfU3Ihpy5thGXdpPiDL8GskpteNrCpgr0aLcTk00E8sD26x/ZZo1oeDXiJcAmnz3BNcD0D1FUpTrewaOEw=; X-UUID: f330164182ec492bb7d2d01260bf9607-20200708 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 928126492; Wed, 08 Jul 2020 03:16:57 +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; Wed, 8 Jul 2020 03:16:45 +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; Wed, 8 Jul 2020 03:16:46 +0800 From: To: , CC: , , , Subject: [PATCH v2 1/3] mt76: mt7663u: fix memory leak in set key Date: Wed, 8 Jul 2020 03:16:46 +0800 Message-ID: <57b81f8efe7e767616a0d5957728756cbfdfa235.1594148548.git.sean.wang@mediatek.com> X-Mailer: git-send-email 1.7.9.5 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 memory leak in set key. v1 -> v2: - remove unneeded kfree Fixes: eb99cc95c3b6 ("mt76: mt7615: introduce mt7663u support") Signed-off-by: Sean Wang Acked-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt7615/usb.c | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/usb.c b/drivers/net/wireless/mediatek/mt76/mt7615/usb.c index 0ba28d37c414..f3c3ad3509c8 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/usb.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/usb.c @@ -165,12 +165,16 @@ __mt7663u_mac_set_key(struct mt7615_dev *dev, lockdep_assert_held(&dev->mt76.mutex); - if (!sta) - return -EINVAL; + if (!sta) { + err = -EINVAL; + goto out; + } cipher = mt7615_mac_get_cipher(key->cipher); - if (cipher == MT_CIPHER_NONE) - return -EOPNOTSUPP; + if (cipher == MT_CIPHER_NONE) { + err = -EOPNOTSUPP; + goto out; + } wcid = &wd->sta->wcid; @@ -178,19 +182,22 @@ __mt7663u_mac_set_key(struct mt7615_dev *dev, err = mt7615_mac_wtbl_update_key(dev, wcid, key->key, key->keylen, cipher, key->cmd); if (err < 0) - return err; + goto out; err = mt7615_mac_wtbl_update_pk(dev, wcid, cipher, key->keyidx, key->cmd); if (err < 0) - return err; + goto out; if (key->cmd == SET_KEY) wcid->cipher |= BIT(cipher); else wcid->cipher &= ~BIT(cipher); - return 0; +out: + kfree(key->key); + + return err; } void mt7663u_wtbl_work(struct work_struct *work) From patchwork Tue Jul 7 19:16:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Wang X-Patchwork-Id: 11649849 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 EDA886C1 for ; Tue, 7 Jul 2020 19:16:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CFFFA2075B for ; Tue, 7 Jul 2020 19:16:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="Al1fLAqM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728855AbgGGTQ6 (ORCPT ); Tue, 7 Jul 2020 15:16:58 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:16610 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728840AbgGGTQ5 (ORCPT ); Tue, 7 Jul 2020 15:16:57 -0400 X-UUID: 581ff3ed9db14024bc379809d4b02727-20200708 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=6WwLQZSskyqVpi7nnoZklS0XEE0b/m647iz/70QPzhA=; b=Al1fLAqMtxgm9Z4FlGhArPx2AeOHiMhU7dNhq3NmZLuIlN0ZiRz25Xt8yjgvXeEtyw+a6u2I08x8vvGURmYb7SHO9J8qTEIUqxSieUpZF0ixwRrAg7fCSy0AR4A537N2UDJpZkJ/HfZujirydB0p+S3+XkDoEWKoEHu7UUy2y3o=; X-UUID: 581ff3ed9db14024bc379809d4b02727-20200708 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 588844300; Wed, 08 Jul 2020 03:16:52 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 8 Jul 2020 03:16:45 +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; Wed, 8 Jul 2020 03:16:46 +0800 From: To: , CC: , , , Subject: [PATCH v2 2/3] mt76: mt7663u: fix potential memory leak in mcu message handler Date: Wed, 8 Jul 2020 03:16:47 +0800 Message-ID: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <57b81f8efe7e767616a0d5957728756cbfdfa235.1594148548.git.sean.wang@mediatek.com> References: <57b81f8efe7e767616a0d5957728756cbfdfa235.1594148548.git.sean.wang@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: DFAE3EC087A09961308A87017844A1E472331BF8FCC4033435F92BDFEFB911A42000:8 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. v1 -> v2: - add Acked-by tag Fixes: eb99cc95c3b6 ("mt76: mt7615: introduce mt7663u support") Acked-by: Lorenzo Bianconi Signed-off-by: Sean Wang --- drivers/net/wireless/mediatek/mt76/mt7615/usb_mcu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/usb_mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/usb_mcu.c index cd709fd617db..3e66ff98cab8 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/usb_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/usb_mcu.c @@ -34,7 +34,6 @@ mt7663u_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb, ret = mt76u_bulk_msg(&dev->mt76, skb->data, skb->len, NULL, 1000, ep); - dev_kfree_skb(skb); if (ret < 0) goto out; @@ -43,6 +42,7 @@ mt7663u_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb, out: mutex_unlock(&mdev->mcu.mutex); + dev_kfree_skb(skb); return ret; } From patchwork Tue Jul 7 19:16:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Wang X-Patchwork-Id: 11649851 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 2C2A86C1 for ; Tue, 7 Jul 2020 19:17:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0A61A2075B for ; Tue, 7 Jul 2020 19:17:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="jq25Rx78" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728859AbgGGTRA (ORCPT ); Tue, 7 Jul 2020 15:17:00 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:54265 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728840AbgGGTRA (ORCPT ); Tue, 7 Jul 2020 15:17:00 -0400 X-UUID: c58ddb599a124722be53072fa746300f-20200708 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=/WUA0+LRnFB+TGhQ0pQghsVlxdUXTpYr3oN8/7I5g/Q=; b=jq25Rx78OWmVL8dfMgMH6EC3GVo+o3TDtNV/N3OHzq4cg5i60vEzakcRsCHsn1StDTMCvy3ZrYcatUO/WxSi3GhZZYcAWm6kEY0Kt7AXdQaeGQbnI1UV9cZigVZ/aBSxRB+vGe0P60qTSJKgeV8jJr7mYAqOKKhsXOFgOUAOvtw=; X-UUID: c58ddb599a124722be53072fa746300f-20200708 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 1886084432; Wed, 08 Jul 2020 03:16:57 +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; Wed, 8 Jul 2020 03:16:45 +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; Wed, 8 Jul 2020 03:16:46 +0800 From: To: , CC: , , , Subject: [PATCH v2 3/3] mt76: mt7615: fix potential memory leak in mcu message handler Date: Wed, 8 Jul 2020 03:16:48 +0800 Message-ID: <1d14e3065c4cae75ac8c91fcedd5af80f8282413.1594148548.git.sean.wang@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <57b81f8efe7e767616a0d5957728756cbfdfa235.1594148548.git.sean.wang@mediatek.com> References: <57b81f8efe7e767616a0d5957728756cbfdfa235.1594148548.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. v1 -> v2: - add Acked-by tag Fixes: 0e6a29e477f3 ("mt76: mt7615: add support to read temperature from mcu") Acked-by: Lorenzo Bianconi Signed-off-by: Sean Wang --- 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;