Skip to content

Commit 731073b

Browse files
sgruszkadavem330
authored andcommitted
sky2: initialize napi before registering device
There is race condition when call netif_napi_add() after register_netdevice(), as ->open() can be called without napi initialized and trigger BUG_ON() on napi_enable(), like on below messages: [ 9.699863] sky2: driver version 1.30 [ 9.699960] sky2 0000:02:00.0: Yukon-2 EC Ultra chip revision 2 [ 9.700020] sky2 0000:02:00.0: irq 45 for MSI/MSI-X [ 9.700498] ------------[ cut here ]------------ [ 9.703391] kernel BUG at include/linux/netdevice.h:501! [ 9.703391] invalid opcode: 0000 [#1] PREEMPT SMP <snip> [ 9.830018] Call Trace: [ 9.830018] [<fa996169>] sky2_open+0x309/0x360 [sky2] [ 9.830018] [<c1007210>] ? via_no_dac+0x40/0x40 [ 9.830018] [<c1007210>] ? via_no_dac+0x40/0x40 [ 9.830018] [<c135ed4b>] __dev_open+0x9b/0x120 [ 9.830018] [<c1431cbe>] ? _raw_spin_unlock_bh+0x1e/0x20 [ 9.830018] [<c135efd9>] __dev_change_flags+0x89/0x150 [ 9.830018] [<c135f148>] dev_change_flags+0x18/0x50 [ 9.830018] [<c13bb8e0>] devinet_ioctl+0x5d0/0x6e0 [ 9.830018] [<c13bcced>] inet_ioctl+0x6d/0xa0 To fix the problem patch changes the order of initialization. Bug report: https://bugzilla.kernel.org/show_bug.cgi?id=67151 Reported-and-tested-by: ebrahim.azarisooreh@gmail.com Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a452ce3 commit 731073b

File tree

1 file changed

+2
-2
lines changed
  • drivers/net/ethernet/marvell

1 file changed

+2
-2
lines changed

drivers/net/ethernet/marvell/sky2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5020,6 +5020,8 @@ static int sky2_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
50205020
}
50215021
}
50225022

5023+
netif_napi_add(dev, &hw->napi, sky2_poll, NAPI_WEIGHT);
5024+
50235025
err = register_netdev(dev);
50245026
if (err) {
50255027
dev_err(&pdev->dev, "cannot register net device\n");
@@ -5028,8 +5030,6 @@ static int sky2_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
50285030

50295031
netif_carrier_off(dev);
50305032

5031-
netif_napi_add(dev, &hw->napi, sky2_poll, NAPI_WEIGHT);
5032-
50335033
sky2_show_addr(dev);
50345034

50355035
if (hw->ports > 1) {

0 commit comments

Comments
 (0)