Skip to contentSkip to conversation

hinic: fix rewaking txq after netif_tx_disable

PATCH In review Luo bin 2 participants 3 messages Sep 7, 2020 – Sep 8, 2020

Subsystems (3)
lore
Share & tools
lore

Luo bin

author
#0 lore raw

PATCH 1/1 hinic: fix rewaking txq after netif_tx_disable

When calling hinic_close in hinic_set_channels, all queues are stopped after netif_tx_disable, but some queue may be rewaken in free_tx_poll by mistake while drv is handling tx irq. If one queue is rewaken core may call hinic_xmit_frame to send pkt after netif_tx_disable within a short time which may results in accessing memory that has been already freed in hinic_close. So we judge whether the netdev is in down state before waking txq in free_tx_poll to fix this bug.

---
 drivers/net/ethernet/huawei/hinic/hinic_tx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/huawei/hinic/hinic_tx.c +2 -1
index a97498ee6914..6eac6bdf164e 100644
@@ -718,7 +718,8 @@ static int free_tx_poll(struct napi_struct *napi, int budget)
 
 		__netif_tx_lock(netdev_txq, smp_processor_id());
 
-		netif_wake_subqueue(nic_dev->netdev, qp->q_id);
+		if (nic_dev->flags & HINIC_INTF_UP)
+			netif_wake_subqueue(nic_dev->netdev, qp->q_id);
 
 		__netif_tx_unlock(netdev_txq);
 
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 8 lines · On Mon, 7 Sep 2020 22:15:16 +0800 Luo bin wrote:

When calling hinic_close in hinic_set_channels, all queues are stopped after netif_tx_disable, but some queue may be rewaken in free_tx_poll by mistake while drv is handling tx irq. If one queue is rewaken core may call hinic_xmit_frame to send pkt after netif_tx_disable within a short time which may results in accessing memory that has been already freed in hinic_close. So we judge whether the netdev is in down state before waking txq in free_tx_poll to fix this bug.

The right fix is to call napi_disable() _before_ you call netif_tx_disable(), not after, like hinic_close() does.

author
#2 lore raw
Quoted 10 lines · Jakub Kicinski
Quoted 8 lines · On Mon, 7 Sep 2020 22:15:16 +0800 Luo bin wrote:

When calling hinic_close in hinic_set_channels, all queues are stopped after netif_tx_disable, but some queue may be rewaken in free_tx_poll by mistake while drv is handling tx irq. If one queue is rewaken core may call hinic_xmit_frame to send pkt after netif_tx_disable within a short time which may results in accessing memory that has been already freed in hinic_close. So we judge whether the netdev is in down state before waking txq in free_tx_poll to fix this bug.

Quoted 4 lines

The right fix is to call napi_disable() _before_ you call netif_tx_disable(), not after, like hinic_close() does. .

Will fix. Thanks for your review.