linux_dsm_epyc7002/drivers/net
Jon Maxwell f37bd0cced cnic: call cp->stop_hw() in cnic_start_hw() on allocation failure
We recently had a system crash in the cnic module. Vmcore analysis confirmed
that "ip link up" was executed which failed due to an allocation failure
because of memory fragmentation. Futher analysis revealed that the cnic irq
vector was still allocated after the "ip link up" that failed. When
"ip link down" was executed it called free_msi_irqs() which crashed the system
because the cnic irq was still inuse.

PANIC: "kernel BUG at drivers/pci/msi.c:411!"

The code execution was:

cnic_netdev_event()
if (event == NETDEV_UP) {
.
.
       ▹       if (!cnic_start_hw(dev))
cnic_start_hw()
calls cnic_cm_open() which failed with -ENOMEM
cnic_start_hw() then took the err1 path:

err1:↩
       cp->free_resc(dev);↩ <---- frees resources but not irq vector
       pci_dev_put(dev->pcidev);↩
       return err;↩
}↩

This returns control back to cnic_netdev_event() but now the cnic irq vector
is still allocated even although cnic_cm_open() failed. The next
"ip link down" while trigger the crash.

The cnic_start_hw() routine is not handling the allocation failure correctly.
Fix this by checking whether CNIC_DRV_STATE_HANDLES_IRQ flag is set indicating
that the hardware has been started in cnic_start_hw(). If it has then call
cp->stop_hw() which frees the cnic irq vector and cnic resources. Otherwise
just maintain the previous behaviour and free cnic resources.

I reproduced this by injecting an ENOMEM error into cnic_cm_alloc_mem()s return
code.

# ip link set dev enpX down
# ip link set dev enpX up <--- hit's allocation failure
# ip link set dev enpX down <--- crashes here

With this patch I confirmed there was no crash in the reproducer.

Signed-off-by: Jon Maxwell <jmaxwell37@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-05-06 15:44:54 -04:00
..
appletalk treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
arcnet arcnet: com90xx: add __init attribute 2016-04-19 20:17:45 -04:00
bonding
caif
can treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
cris treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
dsa Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-05-04 00:52:29 -04:00
ethernet cnic: call cp->stop_hw() in cnic_start_hw() on allocation failure 2016-05-06 15:44:54 -04:00
fddi
fjes treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
hamradio treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
hippi
hyperv hv_netvsc: Fix the list processing for network change event 2016-04-24 23:27:58 -04:00
ieee802154 ieee802154: atusb: update my copyright years for this driver 2016-04-21 00:21:28 +02:00
ipvlan ipvlan: Fix failure path in dev registration during link creation 2016-04-28 17:23:08 -04:00
irda treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
phy mdio_bus: don't return NULL from mdiobus_scan() 2016-05-04 16:14:19 -04:00
plip
ppp ppp: add rtnetlink device creation support 2016-04-29 16:09:44 -04:00
slip treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
team team: team should sync the port's uc/mc addrs when add a port 2016-03-30 17:06:58 -04:00
usb usbnet: smsc95xx: silence an uninitialized variable warning 2016-05-04 16:58:57 -04:00
vmxnet3 Driver: Vmxnet3: set CHECKSUM_UNNECESSARY for IPv6 packets 2016-04-21 15:28:05 -04:00
wan treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
wimax treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
wireless treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
xen-netback
dummy.c
eql.c
geneve.c geneve: break dependency with netdev drivers 2016-04-21 15:35:44 -04:00
ifb.c
Kconfig net: dummy: remove note about being Y by default 2016-04-26 01:11:55 -04:00
LICENSE.SRC
loopback.c
macsec.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-04-27 15:43:10 -04:00
macvlan.c macvlan: fix failure during registration v3 2016-04-26 15:17:18 -04:00
macvtap.c macvtap: check minor when unregistering 2016-04-26 15:17:45 -04:00
Makefile
mdio.c
mii.c
netconsole.c
nlmon.c
ntb_netdev.c
rionet.c drivers: net: remove NETDEV_TX_LOCKED 2016-04-26 15:53:05 -04:00
sb1000.c
Space.c
sungem_phy.c
tun.c tuntap: calculate rps hash only when needed 2016-04-28 16:38:54 -04:00
veth.c veth: Update features to include all tunnel GSO types 2016-04-21 14:14:59 -04:00
virtio_net.c
vrf.c net: vrf: Fix dst reference counting 2016-04-11 15:56:20 -04:00
vxlan.c vxlan: fix initialization with custom link parameters 2016-04-29 15:08:56 -04:00
xen-netfront.c