Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2632957pxa; Mon, 17 Aug 2020 15:00:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbg5OZMPIzIdeUEZOB+MgvoiUSfrNdyJKHbgZytIdQW3c6EpkEPESxXN4hPE5fRtIum+9Z X-Received: by 2002:a17:906:c8d2:: with SMTP id gc18mr18299068ejb.24.1597701641722; Mon, 17 Aug 2020 15:00:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597701641; cv=none; d=google.com; s=arc-20160816; b=u0wR5yQIsZHMPT3rGtO2qlDvKfE+03rYxc/eZXoHsVVY/q1QHtYip1yBFEukHg0paJ UFF2+/IS3Niv84chLKsOi4dM9o+6RxCVpoFgosZAl34+YK7XfpNtxLgAzg9ITPrDdpSP st2CAk2fGJnk3Mjy4Lf0hDCq1z++1u0hP4c6CDxKafTGu51xieZmArP7MIJIkXVby4Dg iBd+XbIO26+N8FSgiWzblBCNbresfprjGe+jrSYDZHlNPJmcOgtkKH3AjBo++qql7TB7 8L4R0iwGuZwu9tKJofl0hwOcjTvb9Iu1tUnvXggZvzBNhRgEeU12tBCo1XpJyQ+qEELx jXvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6BDLdfUlLNTqeVCDmK4OR70xx30JGFXM8OAU3fIn6Bo=; b=0bRQQAVf+7LGktGRC3j3lR3964ZQR5IA7XFZ8vP0LMWS59424San3VI8FssExkOf/L UfI2F9RF3aNCnUGXhulqIoAHO2xMV9HkktMxn/ngVsf0KcRbUJukOMkYg1dQkdakF30d w0TWxW3J5YFAPM/Ho+2D/Bql/0bo2TWBCToA0VGCJ1DUZUu0OWvRT8J82lydrJjDml9Z OPGn5divpSLxZ0fPZd7L2cHK/5WdwsRwIRN3TmVS66EiRm6gMw76m9WHZrR7mwgsAZV/ 1iLC8Oaifw7FzvKF39JA4g+PTjGEHjMsoJfsZaADr40JKjJsVSAiGvDsk4o7UN0xd1Z0 Fxvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ANpKm++I; 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 a3si11876292edk.48.2020.08.17.15.00.17; Mon, 17 Aug 2020 15:00:41 -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=ANpKm++I; 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 S1730269AbgHQPgi (ORCPT + 99 others); Mon, 17 Aug 2020 11:36:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:52802 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730213AbgHQPam (ORCPT ); Mon, 17 Aug 2020 11:30:42 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 6334C2245C; Mon, 17 Aug 2020 15:30:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597678241; bh=fJL/l3YfGc/gPwQbdodajskzq+mBQmY7RH0VafRmsnA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ANpKm++Iq3jV8cJQMThpquo5oL/H8pzYGI3gntTlRuLLbUQRMkPv+5ck0I19HtE5E ZmrvLZHtq3tO4Ae4y8lr/iKB+/Zm5odt26/z9XxxL2WQC6FvAFWrkFdAWSxgcreas2 sjusnYyZ0cuWCd77G5hzDYDu5HF627i0KXa+5qQQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Wang , Lorenzo Bianconi , Felix Fietkau , Sasha Levin Subject: [PATCH 5.8 267/464] mt76: mt7663u: fix memory leak in set key Date: Mon, 17 Aug 2020 17:13:40 +0200 Message-Id: <20200817143846.576307361@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143833.737102804@linuxfoundation.org> References: <20200817143833.737102804@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Wang [ Upstream commit 4a850f8dc68b8c4a20333521b31600c9d31ccb5d ] Fix memory leak in set key. Fixes: eb99cc95c3b6 ("mt76: mt7615: introduce mt7663u support") Signed-off-by: Sean Wang Acked-by: Lorenzo Bianconi Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin --- .../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 5be6704770ad0..7906e6a71c5b9 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/usb.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/usb.c @@ -166,12 +166,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; @@ -179,19 +183,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) -- 2.25.1