Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9116181pxu; Mon, 28 Dec 2020 07:03:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJxpTYW2WSoN2yeKn4UR8RiOoQsHHAmEGyeZkuDmeofVSQRgVDm+YPPSBjOmKIbNwG0DAX14 X-Received: by 2002:a17:906:3401:: with SMTP id c1mr43109791ejb.156.1609167816364; Mon, 28 Dec 2020 07:03:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609167816; cv=none; d=google.com; s=arc-20160816; b=wUlKCNajTkIdDQ/lJ2QFosAC+QzB71PiIKDNBD2gAuXcyRBhGL7yoLcOovsvJlUmiu Enb4dECPNVGJoeDZHSWBR/Uxbn1bhSvyXXqVoLlsKN9Wvh2cBDFcOkDEm4NlC/rHGotN jh5sjcFIHGlpsLePGsJih2ZL/Idnh+j6eWsU/qfni/hyzbfWakif27EXAgfa4KY5c9Jy 8t6IabOqPAe4CApmKvO7QtW18YD12bg/oSd5gdFFb37RuyhXhZr36O0TbGamhhtLP5qS llUmyq/szElHbu9J4GW776qrNa5y2wsqcNDLHB9yiNLXqV3NK3ZoM4N6uGJpb4asbhuj DiHQ== 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=gTw5Cidtvn59YVXhFGPSnwDQ5MDaBBqgvxnPvGKJPF4=; b=M4ZBo9ocpQn+62vcTNhAWO9t+Nmo6kyT//YPldboONsOLYb6MjuQoysu1R7AhwQBME xfjvTmksbqhqVWM+D5iIOas+gwWn6bCc7NTVjLOdwDzsTameDMnHHqk5jLu97duwr6KT UPdkKC8RWeaqFOILCL8rXZh+dL/sDfuGKhphcCqPtY6qLZyNpVaEFxrfS9xR9C0JTbAJ ILmljIJKFZKhMOezcLQkgylyeS3AQfPVZxrKrHvYIF2KyOIVuNPvKb0EJputMEyxP1US HScW2u4gTuNaWIfy0NhyWbAw/ib216T+Ll/aW7bZPDd2Q/3UAOyy7zPw6G+OL54093Ri +2vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BSZA4xs0; 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=pass (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 eb11si21018498edb.446.2020.12.28.07.03.11; Mon, 28 Dec 2020 07:03:36 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=BSZA4xs0; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392516AbgL1PAo (ORCPT + 99 others); Mon, 28 Dec 2020 10:00:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:47362 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440265AbgL1ONv (ORCPT ); Mon, 28 Dec 2020 09:13:51 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9E17F205CB; Mon, 28 Dec 2020 14:13:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609164816; bh=jFVmtSDrJWKo8NAfmlnhVC/H6IFl7Pdu6U35T7j7Dek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BSZA4xs0zwzVtpadBpABHFlBSl+xSsaRIzpgyeVD/xnSNJ4HFWmcHfSk32KV7LWeS fB2TiR3occCP1Nep0qvPsp3EjH8w9HBHCktEshmXwGRyGvvojFtjZRlcBp8HZHQe89 k3soTxTHbLv+PYc2OApzjvuCqeNg/3o+mbAJIG5k= 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.10 307/717] mt76: fix memory leak if device probing fails Date: Mon, 28 Dec 2020 13:45:05 +0100 Message-Id: <20201228125035.736189244@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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: Lorenzo Bianconi [ Upstream commit bc348defcc6eceeb4f7784bf9a263ddb72fd3fb4 ] Run mt76_free_device instead of ieee80211_free_hw if device probing fails in order to remove the already allocated mt76 workqueue Fixes: a86f1d01f5ce5 ("mt76: move mt76 workqueue in common code") Fixes: f1d962369d568 ("mt76: mt7915: implement HE per-rate tx power support") Signed-off-by: Lorenzo Bianconi Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin --- drivers/net/wireless/mediatek/mt76/mt7603/pci.c | 3 ++- drivers/net/wireless/mediatek/mt76/mt7615/mmio.c | 3 ++- drivers/net/wireless/mediatek/mt76/mt76x0/pci.c | 3 ++- drivers/net/wireless/mediatek/mt76/mt76x2/pci.c | 3 ++- drivers/net/wireless/mediatek/mt76/mt7915/pci.c | 5 +++-- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/pci.c b/drivers/net/wireless/mediatek/mt76/mt7603/pci.c index a5845da3547a9..06fa28f645f28 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/pci.c @@ -57,7 +57,8 @@ mt76pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) return 0; error: - ieee80211_free_hw(mt76_hw(dev)); + mt76_free_device(&dev->mt76); + return ret; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mmio.c b/drivers/net/wireless/mediatek/mt76/mt7615/mmio.c index 6de492a4cf025..9b191307e140e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mmio.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mmio.c @@ -240,7 +240,8 @@ int mt7615_mmio_probe(struct device *pdev, void __iomem *mem_base, return 0; error: - ieee80211_free_hw(mt76_hw(dev)); + mt76_free_device(&dev->mt76); + return ret; } diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c index dda11c704abaa..b87d8e136cb9a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c @@ -194,7 +194,8 @@ mt76x0e_probe(struct pci_dev *pdev, const struct pci_device_id *id) return 0; error: - ieee80211_free_hw(mt76_hw(dev)); + mt76_free_device(&dev->mt76); + return ret; } diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci.c index 4d50dad29ddff..ecaf85b483ac3 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci.c @@ -90,7 +90,8 @@ mt76x2e_probe(struct pci_dev *pdev, const struct pci_device_id *id) return 0; error: - ieee80211_free_hw(mt76_hw(dev)); + mt76_free_device(&dev->mt76); + return ret; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/pci.c b/drivers/net/wireless/mediatek/mt76/mt7915/pci.c index fe62b4d853e48..3ac5bbb94d294 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/pci.c @@ -140,7 +140,7 @@ static int mt7915_pci_probe(struct pci_dev *pdev, dev = container_of(mdev, struct mt7915_dev, mt76); ret = mt7915_alloc_device(pdev, dev); if (ret) - return ret; + goto error; mt76_mmio_init(&dev->mt76, pcim_iomap_table(pdev)[0]); mdev->rev = (mt7915_l1_rr(dev, MT_HW_CHIPID) << 16) | @@ -163,7 +163,8 @@ static int mt7915_pci_probe(struct pci_dev *pdev, return 0; error: - ieee80211_free_hw(mt76_hw(dev)); + mt76_free_device(&dev->mt76); + return ret; } -- 2.27.0