Skip to content

Commit 442866f

Browse files
Zhu Yanjundavem330
authored andcommitted
bnx2x: fix slowpath null crash
When "NETDEV WATCHDOG: em4 (bnx2x): transmit queue 2 timed out" occurs, BNX2X_SP_RTNL_TX_TIMEOUT is set. In the function bnx2x_sp_rtnl_task, bnx2x_nic_unload and bnx2x_nic_load are executed to shutdown and open NIC. In the function bnx2x_nic_load, bnx2x_alloc_mem allocates dma failure. The message "bnx2x: [bnx2x_alloc_mem:8399(em4)]Can't allocate memory" pops out. The variable slowpath is set to NULL. When shutdown the NIC, the function bnx2x_nic_unload is called. In the function bnx2x_nic_unload, the following functions are executed. bnx2x_chip_cleanup bnx2x_set_storm_rx_mode bnx2x_set_q_rx_mode bnx2x_set_q_rx_mode bnx2x_config_rx_mode bnx2x_set_rx_mode_e2 In the function bnx2x_set_rx_mode_e2, the variable slowpath is operated. Then the crash occurs. To fix this crash, the variable slowpath is checked. And in the function bnx2x_sp_rtnl_task, after dma memory allocation fails, another shutdown and open NIC is executed. CC: Joe Jin <[email protected]> CC: Junxiao Bi <[email protected]> Signed-off-by: Zhu Yanjun <[email protected]> Acked-by: Ariel Elior <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0c3ce16 commit 442866f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9332,7 +9332,7 @@ void bnx2x_chip_cleanup(struct bnx2x *bp, int unload_mode, bool keep_link)
93329332
/* Schedule the rx_mode command */
93339333
if (test_bit(BNX2X_FILTER_RX_MODE_PENDING, &bp->sp_state))
93349334
set_bit(BNX2X_FILTER_RX_MODE_SCHED, &bp->sp_state);
9335-
else
9335+
else if (bp->slowpath)
93369336
bnx2x_set_storm_rx_mode(bp);
93379337

93389338
/* Cleanup multicast configuration */
@@ -10271,8 +10271,15 @@ static void bnx2x_sp_rtnl_task(struct work_struct *work)
1027110271
smp_mb();
1027210272

1027310273
bnx2x_nic_unload(bp, UNLOAD_NORMAL, true);
10274-
bnx2x_nic_load(bp, LOAD_NORMAL);
10275-
10274+
/* When ret value shows failure of allocation failure,
10275+
* the nic is rebooted again. If open still fails, a error
10276+
* message to notify the user.
10277+
*/
10278+
if (bnx2x_nic_load(bp, LOAD_NORMAL) == -ENOMEM) {
10279+
bnx2x_nic_unload(bp, UNLOAD_NORMAL, true);
10280+
if (bnx2x_nic_load(bp, LOAD_NORMAL))
10281+
BNX2X_ERR("Open the NIC fails again!\n");
10282+
}
1027610283
rtnl_unlock();
1027710284
return;
1027810285
}

0 commit comments

Comments
 (0)