Skip to contentSkip to conversation

brcmfmac: Do not crash if platform data is not populated

PATCH Applied Mika Westerberg 3 participants 7 messages Dec 23, 2014 – Dec 24, 2014 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 brcmfmac: Do not crash if platform data is not populated

The driver looks for pdata->oob_irq_supported to find out if wowl can be supported. However, not all platforms populate pdata in which case we crash the kernel because of NULL pointer dereference.

Fixes 330b4e4be937 ("brcmfmac: Add wowl support for SDIO devices.")
---
 drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c +2 -2
index 3c06e9365949..9880dae2a569 100644
@@ -1070,7 +1070,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func,
 	 */
 	if ((sdio_get_host_pm_caps(sdiodev->func[1]) & MMC_PM_KEEP_POWER) &&
 	    ((sdio_get_host_pm_caps(sdiodev->func[1]) & MMC_PM_WAKE_SDIO_IRQ) ||
-	     (sdiodev->pdata->oob_irq_supported)))
+	     (sdiodev->pdata && sdiodev->pdata->oob_irq_supported)))
 		bus_if->wowl_supported = true;
 #endif
 
@@ -1167,7 +1167,7 @@ static int brcmf_ops_sdio_resume(struct device *dev)
 	struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio;
 
 	brcmf_dbg(SDIO, "Enter\n");
-	if (sdiodev->pdata->oob_irq_supported)
+	if (sdiodev->pdata && sdiodev->pdata->oob_irq_supported)
 		disable_irq_wake(sdiodev->pdata->oob_irq_nr);
 	brcmf_sdio_wd_timer(sdiodev->bus, BRCMF_WD_POLL_MS);
 	atomic_set(&sdiodev->suspend, false);
Signature · 1 line
2.1.3
#1 lore raw
Quoted 3 lines · Mika Westerberg

The driver looks for pdata->oob_irq_supported to find out if wowl can be supported. However, not all platforms populate pdata in which case we crash the kernel because of NULL pointer dereference.

Thanks, Mika

However, this was already reported by Dan Carpenter and I submitted a patch for that a couple of days ago: "[PATCH 02/10] brcmfmac: Fix possible dereference of NULL pointer." [1].

Regards,
Arend

[1] http://mid.gmane.org/[email protected]

Quoted 29 lines
Fixes 330b4e4be937 ("brcmfmac: Add wowl support for SDIO devices.")
---
  drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c +2 -2
index 3c06e9365949..9880dae2a569 100644
@@ -1070,7 +1070,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func,
  	 */
  	if ((sdio_get_host_pm_caps(sdiodev->func[1])&  MMC_PM_KEEP_POWER)&&
  	((sdio_get_host_pm_caps(sdiodev->func[1])&  MMC_PM_WAKE_SDIO_IRQ) ||
-	     (sdiodev->pdata->oob_irq_supported)))
+	     (sdiodev->pdata&&  sdiodev->pdata->oob_irq_supported)))
  		bus_if->wowl_supported = true;
  #endif
 
@@ -1167,7 +1167,7 @@ static int brcmf_ops_sdio_resume(struct device *dev)
  	struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio;
 
  	brcmf_dbg(SDIO, "Enter\n");
-	if (sdiodev->pdata->oob_irq_supported)
+	if (sdiodev->pdata&&  sdiodev->pdata->oob_irq_supported)
  		disable_irq_wake(sdiodev->pdata->oob_irq_nr);
  	brcmf_sdio_wd_timer(sdiodev->bus, BRCMF_WD_POLL_MS);
  	atomic_set(&sdiodev->suspend, false);
#2 lore raw
Quoted 11 lines · Arend van Spriel
Quoted 3 lines · Mika Westerberg

The driver looks for pdata->oob_irq_supported to find out if wowl can be supported. However, not all platforms populate pdata in which case we crash the kernel because of NULL pointer dereference.

Thanks, Mika

However, this was already reported by Dan Carpenter and I submitted a patch for that a couple of days ago: "[PATCH 02/10] brcmfmac: Fix possible dereference of NULL pointer." [1].

Quoted 5 lines

Regards,
Arend

[1]
http://mid.gmane.org/[email protected]

Oh, good. I didn't notice that one.

Thanks for fixing it :)

BTW, that patch seems to miss brcmf_ops_sdio_resume(), perhaps it is fixed in another patch?

#3 lore raw
Quoted 18 lines · Mika Westerberg
Quoted 11 lines · Arend van Spriel
Quoted 3 lines · Mika Westerberg

The driver looks for pdata->oob_irq_supported to find out if wowl can be supported. However, not all platforms populate pdata in which case we crash the kernel because of NULL pointer dereference.

Thanks, Mika

However, this was already reported by Dan Carpenter and I submitted a patch for that a couple of days ago: "[PATCH 02/10] brcmfmac: Fix possible dereference of NULL pointer." [1].

Quoted 5 lines

Regards,
Arend

[1]
http://mid.gmane.org/[email protected]

Quoted 6 lines

Oh, good. I didn't notice that one.

Thanks for fixing it :)

BTW, that patch seems to miss brcmf_ops_sdio_resume(), perhaps it is fixed in another patch?

Aargh, a nice "BTW" this is as there is no other patch for the resume code. Maybe I should ask Kalle to apply your patch instead of ours. If it did not already got applied.

Regards,
Arend

#4 lore raw
Quoted 21 lines · Arend van Spriel
Quoted 20 lines · Mika Westerberg
Quoted 11 lines · Arend van Spriel
Quoted 3 lines · Mika Westerberg

The driver looks for pdata->oob_irq_supported to find out if wowl can be supported. However, not all platforms populate pdata in which case we crash the kernel because of NULL pointer dereference.

Thanks, Mika

However, this was already reported by Dan Carpenter and I submitted a patch for that a couple of days ago: "[PATCH 02/10] brcmfmac: Fix possible dereference of NULL pointer." [1].

Quoted 5 lines

Regards,
Arend

[1]
http://mid.gmane.org/[email protected]

Oh, good. I didn't notice that one.

Quoted 8 lines
Quoted 4 lines

Thanks for fixing it :)

BTW, that patch seems to miss brcmf_ops_sdio_resume(), perhaps it is fixed in another patch?

Aargh, a nice "BTW" this is as there is no other patch for the resume code. Maybe I should ask Kalle to apply your patch instead of ours. If it did not already got applied.

I have been waiting for net-next to open so I haven't applied any -next patches yet. So if you want I can take Mika's patch as well. Just send a reply to your patch I should drop.

And should this patch go to 3.19?

Signature · 1 line
Kalle Valo
#5 lore raw
Quoted 32 lines · Kalle Valo
Quoted 21 lines · Arend van Spriel
Quoted 20 lines · Mika Westerberg
Quoted 11 lines · Arend van Spriel
Quoted 3 lines · Mika Westerberg

The driver looks for pdata->oob_irq_supported to find out if wowl can be supported. However, not all platforms populate pdata in which case we crash the kernel because of NULL pointer dereference.

Thanks, Mika

However, this was already reported by Dan Carpenter and I submitted a patch for that a couple of days ago: "[PATCH 02/10] brcmfmac: Fix possible dereference of NULL pointer." [1].

Quoted 5 lines

Regards,
Arend

[1]
http://mid.gmane.org/[email protected]

Oh, good. I didn't notice that one.

Quoted 8 lines
Quoted 4 lines

Thanks for fixing it :)

BTW, that patch seems to miss brcmf_ops_sdio_resume(), perhaps it is fixed in another patch?

Aargh, a nice "BTW" this is as there is no other patch for the resume code. Maybe I should ask Kalle to apply your patch instead of ours. If it did not already got applied.

Quoted 5 lines

I have been waiting for net-next to open so I haven't applied any -next patches yet. So if you want I can take Mika's patch as well. Just send a reply to your patch I should drop.

And should this patch go to 3.19?

Yeah, the issue was introduced in 3.19 so that makes sense.

Regards,
Arend

Applied
#6 lore raw
In reply to Mika Westerberg
Quoted 7 lines · Mika Westerberg

The driver looks for pdata->oob_irq_supported to find out if wowl can be supported. However, not all platforms populate pdata in which case we crash the kernel because of NULL pointer dereference.

Fixes 330b4e4be937 ("brcmfmac: Add wowl support for SDIO devices.")

Thanks, applied to wireless-drivers.git.

Signature · 1 line
Kalle Valo