mirror of
https://github.com/outbackdingo/mt76.git
synced 2026-10-24 13:26:48 +00:00
wifi: mt76: mt7921: fix resource leak in probe error path
When pcim_iomap_region() or devm_kmemdup() fail, the code returns
directly without cleaning up previously allocated resources:
- mt76_device allocated by mt76_alloc_device()
- pci irq vectors allocated by pci_alloc_irq_vectors()
Fix this by jumping to the existing error cleanup path instead of
returning directly.
Fixes: ee5bb35d2b83 ("wifi: mt76: mt7921: switch to pcim_iomap_region")
Signed-off-by: Hongling Zeng <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
committed by
Felix Fietkau
parent
381582f2a5
commit
d463ed9490
+8
-4
@@ -344,8 +344,10 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
|
||||
pci_set_drvdata(pdev, mdev);
|
||||
|
||||
regs = pcim_iomap_region(pdev, 0, pci_name(pdev));
|
||||
if (IS_ERR(regs))
|
||||
return PTR_ERR(regs);
|
||||
if (IS_ERR(regs)) {
|
||||
ret = PTR_ERR(regs);
|
||||
goto err_free_dev;
|
||||
}
|
||||
|
||||
dev = container_of(mdev, struct mt792x_dev, mt76);
|
||||
dev->fw_features = features;
|
||||
@@ -359,8 +361,10 @@ static int mt7921_pci_probe(struct pci_dev *pdev,
|
||||
/* MT7902 needs a mutable copy because wm2_complete_mask differs */
|
||||
map = devm_kmemdup(&pdev->dev, &irq_map,
|
||||
sizeof(irq_map), GFP_KERNEL);
|
||||
if (!map)
|
||||
return -ENOMEM;
|
||||
if (!map) {
|
||||
ret = -ENOMEM;
|
||||
goto err_free_dev;
|
||||
}
|
||||
|
||||
map->rx.wm2_complete_mask = 0;
|
||||
dev->irq_map = map;
|
||||
|
||||
Reference in New Issue
Block a user