Re: [PATCH net v2] tg3: Avoid NULL pointer dereference in tg3_io_error_detected()
From: David Miller <davem@davemloft.net>
Date: 2016-09-30 05:28:16
From: David Miller <davem@davemloft.net>
Date: 2016-09-30 05:28:16
From: "Guilherme G. Piccoli" <redacted> Date: Thu, 29 Sep 2016 13:24:08 -0300
From: Milton Miller <redacted> While the driver is probing the adapter, an error may occur before the netdev structure is allocated and attached to pci_dev. In this case, not only netdev isn't available, but the tg3 private structure is also not available as it is just math from the NULL pointer, so dereferences must be skipped. The following trace is seen when the error is triggered:
...
This patch avoids the NULL pointer dereference by moving the access after
the netdev NULL pointer check on tg3_io_error_detected(). Also, we add a
check for netdev being NULL on tg3_io_resume() [suggested by Michael Chan].
Fixes: 0486a063b1ff ("tg3: prevent ifup/ifdown during PCI error recovery")
Fixes: dfc8f370316b ("net/tg3: Release IRQs on permanent error")
Tested-by: Guilherme G. Piccoli <redacted>
Signed-off-by: Milton Miller <redacted>
Signed-off-by: Guilherme G. Piccoli <redacted>
---
* v2 changelog: added netdev NULL check on tg3_io_resume() as per
Michael Chan's suggestion.Applied and queued up for -stable, thanks!