* [PATCH net] hinic: fix rewaking txq after netif_tx_disable
@ 2020-09-07 14:15 Luo bin
2020-09-07 21:28 ` Jakub Kicinski
0 siblings, 1 reply; 3+ messages in thread
From: Luo bin @ 2020-09-07 14:15 UTC (permalink / raw)
To: davem
Cc: linux-kernel, netdev, luoxianjun, yin.yinshi, cloud.wangxiaoyun,
chiqijun
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.
Signed-off-by: Luo bin <luobin9@huawei.com>
---
drivers/net/ethernet/huawei/hinic/hinic_tx.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_tx.c b/drivers/net/ethernet/huawei/hinic/hinic_tx.c
index a97498ee6914..6eac6bdf164e 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_tx.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_tx.c
@@ -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);
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] hinic: fix rewaking txq after netif_tx_disable
2020-09-07 14:15 [PATCH net] hinic: fix rewaking txq after netif_tx_disable Luo bin
@ 2020-09-07 21:28 ` Jakub Kicinski
2020-09-08 15:25 ` luobin (L)
0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2020-09-07 21:28 UTC (permalink / raw)
To: Luo bin
Cc: davem, linux-kernel, netdev, luoxianjun, yin.yinshi,
cloud.wangxiaoyun, chiqijun
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] hinic: fix rewaking txq after netif_tx_disable
2020-09-07 21:28 ` Jakub Kicinski
@ 2020-09-08 15:25 ` luobin (L)
0 siblings, 0 replies; 3+ messages in thread
From: luobin (L) @ 2020-09-08 15:25 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, linux-kernel, netdev, luoxianjun, yin.yinshi,
cloud.wangxiaoyun, chiqijun
On 2020/9/8 5:28, Jakub Kicinski wrote:
> 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.
> .
>
Will fix. Thanks for your review.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-08 17:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-07 14:15 [PATCH net] hinic: fix rewaking txq after netif_tx_disable Luo bin
2020-09-07 21:28 ` Jakub Kicinski
2020-09-08 15:25 ` luobin (L)
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.