]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
mt76: mt7921: Fix the error handling path of mt7921_pci_probe()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 3 Apr 2022 15:40:33 +0000 (17:40 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 10 Aug 2022 07:24:28 +0000 (09:24 +0200)
BugLink: https://bugs.launchpad.net/bugs/1981864
[ Upstream commit 4e90db5e21eb3bb272fe47386dc3506755e209e9 ]

In case of error, some resources must be freed, as already done above and
below the devm_kmemdup() and __mt7921e_mcu_drv_pmctrl() calls added in the
commit in Fixes:.

Fixes: 602cc0c9618a ("mt76: mt7921e: fix possible probe failure after reboot")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/net/wireless/mediatek/mt76/mt7921/pci.c

index 15dd6ae7cfe44ca68f6dbfea8793a9140e29db1e..2a42ddf103efb247d4984025c6c916df2d11c6df 100644 (file)
@@ -261,8 +261,10 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
        dev->bus_ops = dev->mt76.bus;
        bus_ops = devm_kmemdup(dev->mt76.dev, dev->bus_ops, sizeof(*bus_ops),
                               GFP_KERNEL);
-       if (!bus_ops)
-               return -ENOMEM;
+       if (!bus_ops) {
+               ret = -ENOMEM;
+               goto err_free_dev;
+       }
 
        bus_ops->rr = mt7921_rr;
        bus_ops->wr = mt7921_wr;
@@ -271,7 +273,7 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
 
        ret = __mt7921_mcu_drv_check_pmctrl(dev);
        if(ret)
-               return ret;
+               goto err_free_dev;
 
        mdev->rev = (mt7921_l1_rr(dev, MT_HW_CHIPID) << 16) |
                    (mt7921_l1_rr(dev, MT_HW_REV) & 0xff);