linux/drivers/net/ethernet
Milton Miller 1b0ff89852 tg3: Avoid NULL pointer dereference in tg3_io_error_detected()
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:

  [1.402247] Unable to handle kernel paging request for data at address 0x00001a99
  [1.402410] Faulting instruction address: 0xc0000000007e33f8
  [1.402450] Oops: Kernel access of bad area, sig: 11 [#1]
  [1.402481] SMP NR_CPUS=2048 NUMA PowerNV
  [1.402513] Modules linked in:
  [1.402545] CPU: 0 PID: 651 Comm: eehd Not tainted 4.4.0-36-generic #55-Ubuntu
  [1.402591] task: c000001fe4e42a20 ti: c000001fe4e88000 task.ti: c000001fe4e88000
  [1.402742] NIP: c0000000007e33f8 LR: c0000000007e3164 CTR: c000000000595ea0
  [1.402787] REGS: c000001fe4e8b790 TRAP: 0300   Not tainted  (4.4.0-36-generic)
  [1.402832] MSR: 9000000100009033 <SF,HV,EE,ME,IR,DR,RI,LE>  CR: 28000422  XER: 20000000
  [1.403058] CFAR: c000000000008468 DAR: 0000000000001a99 DSISR: 42000000 SOFTE: 1
  GPR00: c0000000007e3164 c000001fe4e8ba10 c0000000015c5e00 0000000000000000
  GPR04: 0000000000000001 0000000000000000 0000000000000039 0000000000000299
  GPR08: 0000000000000000 0000000000000001 c000001fe4e88000 0000000000000006
  GPR12: 0000000000000000 c00000000fb40000 c0000000000e6558 c000003ca1bffd00
  GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
  GPR20: 0000000000000000 0000000000000000 0000000000000000 c000000000d52768
  GPR24: c000000000d52740 0000000000000100 c000003ca1b52000 0000000000000002
  GPR28: 0000000000000900 0000000000000000 c00000000152a0c0 c000003ca1b52000
  [1.404226] NIP [c0000000007e33f8] tg3_io_error_detected+0x308/0x340
  [1.404265] LR [c0000000007e3164] tg3_io_error_detected+0x74/0x340

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: 0486a063b1 ("tg3: prevent ifup/ifdown during PCI error recovery")
Fixes: dfc8f37031 ("net/tg3: Release IRQs on permanent error")
Tested-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
Signed-off-by: Milton Miller <miltonm@us.ibm.com>
Signed-off-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
Acked-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-09-30 01:27:27 -04:00
..
3com
8390 net: ethernet: ax88796: avoid null pointer dereference 2016-08-01 13:32:51 -07:00
adaptec
adi net: ethernet: adi: bfin_mac: use phy_ethtool_{get|set}_link_ksettings 2016-07-17 23:22:02 -07:00
aeroflex
agere Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-07-24 00:53:32 -04:00
allwinner
alteon
altera ethernet: altera: add missing of_node_put 2016-08-01 21:42:57 -07:00
amd net: amd-xgbe: use correct format specifier 2016-08-01 13:32:51 -07:00
apm net: xgene: fix maybe-uninitialized variable 2016-08-03 11:52:16 -07:00
apple
arc net: arc_emac: add missing of_node_put() in arc_emac_probe() 2016-08-06 00:07:38 -04:00
atheros Add Killer E2500 device ID in alx driver. 2016-08-29 00:23:50 -04:00
aurora ethernet: aurora: nb8800: add missing of_node_put after calling of_parse_phandle 2016-08-01 21:43:47 -07:00
broadcom tg3: Avoid NULL pointer dereference in tg3_io_error_detected() 2016-09-30 01:27:27 -04:00
brocade bna: fix crash in bnad_get_strings() 2016-09-17 10:18:02 -04:00
cadence net: macb: initialize checksum when using checksum offloading 2016-09-06 13:43:39 -07:00
calxeda
cavium net: thunderx: Fix for issues with multiple CQEs posted for a TSO packet 2016-09-01 14:50:47 -07:00
chelsio cxgb4/cxgb4vf: Allocate more queues for 25G and 100G adapter 2016-09-21 00:48:09 -04:00
cirrus
cisco net: enic: use correct type specifier 2016-08-01 13:32:52 -07:00
davicom dm9000: Fix irq trigger type setup on non-dt platforms 2016-08-09 15:08:22 -07:00
dec net: tulip: fix spelling mistake: "attemping" -> "attempting" 2016-07-30 23:13:51 -07:00
dlink
emulex be2net: perform temperature query in adapter regardless of its interface state 2016-07-26 23:17:42 -07:00
ezchip Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-07-24 00:53:32 -04:00
faraday net/faraday: Disallow using reversed MAC address from hardware 2016-07-20 21:05:18 -07:00
freescale net: fec: align IP header in hardware 2016-09-27 07:39:34 -04:00
fujitsu
hisilicon net: hns: dereference ppe_cb->ppe_common_cb if it is non-null 2016-08-26 11:44:56 -07:00
hp
i825xx
ibm net/ibm/emac: add mutex to 'set multicast list' 2016-09-16 04:21:47 -04:00
intel i40e: Fix kernel panic on enable/disable LLDP 2016-09-01 14:20:28 -07:00
marvell ethernet: marvell: pxa168_eth: add missing of_node_put after calling of_parse_phandle 2016-08-01 21:43:48 -07:00
mediatek net: ethernet: mediatek: fix module loading automatically based on MODULE_DEVICE_TABLE 2016-09-16 04:19:54 -04:00
mellanox net/mlx4_core: Fix to clean devlink resources 2016-09-22 01:41:27 -04:00
micrel
microchip enc28j60: Fix race condition in enc28j60 driver 2016-07-02 14:48:14 -04:00
moxa
myricom
natsemi
neterion net: s2io: simplify logical constraint 2016-08-01 13:32:52 -07:00
netronome nfp: fix error return code in nfp_net_netdev_open() 2016-09-16 04:27:05 -04:00
nuvoton
nvidia
nxp net: lpc_eth: Check clk_prepare_enable() error 2016-08-23 17:10:16 -07:00
oki-semi
packetengines
pasemi net: ethernet: pasemi_mac: use phy_ethtool_{get|set}_link_ksettings 2016-07-15 16:41:34 -07:00
qlogic qed: Fix stack corruption on probe 2016-09-20 04:57:16 -04:00
qualcomm
rdc net: r6040: Bump version and date 2016-07-05 00:10:30 -07:00
realtek 8139cp: Fix one possible deadloop in cp_rx_poll 2016-08-25 17:02:48 -07:00
renesas net: ethernet: renesas: sh_eth: add POST registers for rz 2016-09-10 21:09:10 -07:00
rocker net: add dev arg to ndo_neigh_construct/destroy 2016-07-05 09:06:28 -07:00
samsung net: ethernet: sxgbe: use phy_ethtool_{get|set}_link_ksettings 2016-06-28 09:12:35 -04:00
seeq
sfc sfc: fix potential stack corruption from running past stat bitmask 2016-08-26 21:40:44 -07:00
sgi
silan
sis
smsc net: smsc: remove build warning of duplicate definition 2016-09-06 13:44:33 -07:00
stmicro stmmac: fix PWRDWN into the PMT register for global unicast. 2016-09-18 22:21:06 -04:00
sun
synopsys dwc_eth_qos: do not register semi-initialized device 2016-09-09 19:20:21 -07:00
tehuti net: tehuti: fix typo: "eneble" -> "enable" 2016-08-21 15:21:36 -07:00
ti drivers: net: cpsw: fix kmemleak false-positive reports for sk buffers 2016-08-09 14:54:59 -07:00
tile timers, driver/net/ethernet/tile: Initialize the egress timer as pinned 2016-07-07 10:25:14 +02:00
toshiba net: ethernet: tc35815: use phy_ethtool_{get|set}_link_ksettings 2016-07-15 16:41:33 -07:00
tundra net/ethernet: tundra: fix dump_eth_one warning in tsi108_eth 2016-08-08 13:08:21 -07:00
via
wiznet
xilinx net: xilinx: emaclite: Fallback to random MAC address. 2016-08-20 22:11:29 -07:00
xircom ethernet: xircom: fix spelling mistakes on "excessive collisions" 2016-06-27 04:19:14 -04:00
xscale net: ethernet: ixp4xx_eth: use phy_ethtool_{get|set}_link_ksettings 2016-07-04 15:59:52 -07:00
dnet.c net: ethernet: dnet: use phy_ethtool_{get|set}_link_ksettings 2016-06-28 05:10:26 -04:00
dnet.h net: ethernet: dnet: use phydev from struct net_device 2016-06-28 05:10:26 -04:00
ec_bhf.c
ethoc.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-07-24 00:53:32 -04:00
fealnx.c
jme.c
jme.h
Kconfig
korina.c
lantiq_etop.c net: ethernet: lantiq_etop: use phy_ethtool_{get|set}_link_ksettings 2016-07-04 15:59:51 -07:00
Makefile
netx-eth.c