Skip to contentSkip to conversation

wifi: mt76: mt7996: Fix null-ptr-deref in mt7996_mmio_wed_init()

PATCH Superseded Henry Martin 3 participants 4 messages Apr 7, 2025 – Apr 24, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 wifi: mt76: mt7996: Fix null-ptr-deref in mt7996_mmio_wed_init()

devm_ioremap() returns NULL on error. Currently, mt7996_mmio_wed_init() does not check for this case, which results in a NULL pointer dereference.

Prevent null pointer dereference in mt7996_mmio_wed_init()

Fixes 83eafc9251d6 ("wifi: mt76: mt7996: add wed tx support")

---
V1 -> V2: Add a blank after the check and correct the summary.

 drivers/net/wireless/mediatek/mt76/mt7996/mmio.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7996/mmio.c +3 -0
index 13b188e281bd..af9169030bad 100644
@@ -323,6 +323,9 @@ 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) {
Signature · 1 line
2.34.1
#1 lore raw

…

Quoted 1 line

Prevent null pointer dereference in mt7996_mmio_wed_init()

Would you occasionally like to mark the end of sentences with a dot?

Can any other summary phrase variant become more desirable accordingly?

Regards,
Markus

#2 lore raw
Quoted 5 lines · Markus Elfring

…

Quoted 1 line

Prevent null pointer dereference in mt7996_mmio_wed_init()

Would you occasionally like to mark the end of sentences with a dot?

They did one out of two times. Go away from the wireless list.

johannes

#3 lore raw
In reply to Henry Martin

Hi all,

I’d like to kindly follow up on my previous patch submission to check if there are any additional feedback or suggestions for improvement. If there are further changes needed, I’ll be happy to address them and send a v3.

Please let me know if you have any comments. Thanks for your time and review!

Best regards,

Quoted 32 lines · Henry Martin <[email protected]> 于2025年4月7日周一 11:24写道:

devm_ioremap() returns NULL on error. Currently, mt7996_mmio_wed_init() does not check for this case, which results in a NULL pointer dereference.

Prevent null pointer dereference in mt7996_mmio_wed_init()

Fixes 83eafc9251d6 ("wifi: mt76: mt7996: add wed tx support")

---
V1 -> V2: Add a blank after the check and correct the summary.

 drivers/net/wireless/mediatek/mt76/mt7996/mmio.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7996/mmio.c +3 -1
index 13b188e281bd..af9169030bad 100644
@@ -323,6 +323,9 @@ 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) {
--

2.34.1