Message ID | 20250403064344.64253-1-bsdhenrymartin@gmail.com (mailing list archive) |
---|---|
State | New |
Delegated to: | Felix Fietkau |
Headers | show |
Series | [v1] wifi: mt76: mt7996: Fix null-ptr-deref in mt7996_mmio_wed_init() | expand |
… > Add NULL check after devm_ioremap() to prevent this issue. Can a summary phrase like “Prevent null pointer dereference in mt7996_mmio_wed_init()” be a bit nicer? … > +++ b/drivers/net/wireless/mediatek/mt76/mt7996/mmio.c > @@ -323,6 +323,8 @@ int mt7996_mmio_wed_init(struct mt7996_dev *dev, void *pdev_ptr, > wed->wlan.base = devm_ioremap(dev->mt76.dev, > pci_resource_start(pci_dev, 0), > pci_resource_len(pci_dev, 0)); > + if (!wed->wlan.base) > + return -ENOMEM; Can a blank line be desirable after such a statement? Regards, Markus
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mmio.c b/drivers/net/wireless/mediatek/mt76/mt7996/mmio.c index 13b188e281bd..5bade83238bd 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/mmio.c +++ b/drivers/net/wireless/mediatek/mt76/mt7996/mmio.c @@ -323,6 +323,8 @@ int mt7996_mmio_wed_init(struct mt7996_dev *dev, void *pdev_ptr, wed->wlan.base = devm_ioremap(dev->mt76.dev, pci_resource_start(pci_dev, 0), pci_resource_len(pci_dev, 0)); + if (!wed->wlan.base) + return -ENOMEM; wed->wlan.phy_base = pci_resource_start(pci_dev, 0); if (hif2) {
devm_ioremap() returns NULL on error. Currently, mt7996_mmio_wed_init() does not check for this case, which results in a NULL pointer dereference. Add NULL check after devm_ioremap() to prevent this issue. Fixes: 83eafc9251d6 ("wifi: mt76: mt7996: add wed tx support") Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com> --- drivers/net/wireless/mediatek/mt76/mt7996/mmio.c | 2 ++ 1 file changed, 2 insertions(+)