summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/mediatek/mt76
diff options
context:
space:
mode:
authorLorenzo Bianconi <lorenzo@kernel.org>2020-02-18 21:17:12 +0300
committerFelix Fietkau <nbd@nbd.name>2020-03-17 19:13:58 +0300
commit2da7cc7dce6f080fca2e3991a494d69730529c1d (patch)
tree02bddac93e25d92e4856cae2020d1daff2298575 /drivers/net/wireless/mediatek/mt76
parent44e8f8efd926a5dd75727e1c39e2a0ae968ff3cd (diff)
downloadlinux-2da7cc7dce6f080fca2e3991a494d69730529c1d.tar.xz
mt76: mt76u: fix a possible memory leak in mt76u_init
Remove usb workqueue if mt76u_set_endpoints fails. Fixes: 284efb473ef5 ("mt76: mt76u: rely on a dedicated stats workqueue") Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'drivers/net/wireless/mediatek/mt76')
-rw-r--r--drivers/net/wireless/mediatek/mt76/usb.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c
index fffa12cbb3e3..f771ac02821c 100644
--- a/drivers/net/wireless/mediatek/mt76/usb.c
+++ b/drivers/net/wireless/mediatek/mt76/usb.c
@@ -1157,6 +1157,7 @@ int mt76u_init(struct mt76_dev *dev,
};
struct usb_device *udev = interface_to_usbdev(intf);
struct mt76_usb *usb = &dev->usb;
+ int err = -ENOMEM;
mt76u_ops.rr = ext ? mt76u_rr_ext : mt76u_rr;
mt76u_ops.wr = ext ? mt76u_wr_ext : mt76u_wr;
@@ -1176,10 +1177,8 @@ int mt76u_init(struct mt76_dev *dev,
usb->data_len = 32;
usb->data = devm_kmalloc(dev->dev, usb->data_len, GFP_KERNEL);
- if (!usb->data) {
- mt76u_deinit(dev);
- return -ENOMEM;
- }
+ if (!usb->data)
+ goto error;
mutex_init(&usb->usb_ctrl_mtx);
dev->bus = &mt76u_ops;
@@ -1189,7 +1188,15 @@ int mt76u_init(struct mt76_dev *dev,
usb->sg_en = mt76u_check_sg(dev);
- return mt76u_set_endpoints(intf, usb);
+ err = mt76u_set_endpoints(intf, usb);
+ if (err < 0)
+ goto error;
+
+ return 0;
+
+error:
+ mt76u_deinit(dev);
+ return err;
}
EXPORT_SYMBOL_GPL(mt76u_init);