From patchwork Mon Sep 7 14:15:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luo bin X-Patchwork-Id: 1359111 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BlZdc2dzBz9sR4 for ; Tue, 8 Sep 2020 03:14:28 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731047AbgIGROW (ORCPT ); Mon, 7 Sep 2020 13:14:22 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:11249 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729636AbgIGOO4 (ORCPT ); Mon, 7 Sep 2020 10:14:56 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id C94C9136E6560B3A4875; Mon, 7 Sep 2020 22:14:18 +0800 (CST) Received: from localhost.localdomain (10.175.118.36) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.487.0; Mon, 7 Sep 2020 22:14:08 +0800 From: Luo bin To: CC: , , , , , Subject: [PATCH net] hinic: fix rewaking txq after netif_tx_disable Date: Mon, 7 Sep 2020 22:15:16 +0800 Message-ID: <20200907141516.16817-1-luobin9@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.175.118.36] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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);