Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3165927pxb; Sat, 26 Mar 2022 12:29:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTXBC0eMtJQokIL7DXhr6QSDfAOE5leeX4IbQnGwqv+3xcWVRyJFG187oyQxgynlgpIHed X-Received: by 2002:a17:902:d505:b0:154:76c2:f7bb with SMTP id b5-20020a170902d50500b0015476c2f7bbmr18200100plg.83.1648322962633; Sat, 26 Mar 2022 12:29:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648322962; cv=none; d=google.com; s=arc-20160816; b=hxv3uWP9+RJQlHmJnqy2Z22jY/w+Pm4aXaiOkQiOBmNHq6qzNyiu2h9aumlBtD55zS a+l6YehqJGnkjhUYNhx4xG3ChlsfFdrjhdIxPP5UNhjPycIjXnizXt36wRvM5oEPo+fd fkWvTJHSt7s5zpX6mljkuEu2gqiH7Lsx8KiKgrWdGz9Rnj+dtdGI8XwXX2gjwz/4HDQP 9E/pgiz09E5URTGR+06XbBA4/y0lH6Z9kr8e370e0VuCr0eBhOZH2C6Mo+w7Va0hEJ/m 17klmP3SqTN1xIgp6HSk5sAh3letU+MCB5qcLalCexGbw20FUC5ET+kIWlVvg/tQjeNT oj1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=PVyyMmIgRYnC6Pv9psfaftN9IIMB8ayB+SlBQCOr3Oc=; b=x2STY14T/laqUk2OuVhDGAjHpNjc5Fm5C+N3TxKtH3mLEEMO0NNJZzmNH3XiDhBgcp e9gScKtU1IddbLCOUloikCnFGQNC2fGDReYVmkua5vnhdooq9hRYww549DJPiAkCl18E sIknFIsBQLqkNH2sZdCRS4kpTpJlnik+FpxExreyvRs7eLRpptkjNgR67v516UjLC6Q8 NsE+dmJPCgNcjvyX8Ik2Begzsn01vdOHccBEh9uv8vL+w458OCcKjymO5CU0YdqUNsaF bkfw+o0wZGup8V4rKbxmxi55xvE/8GTkaJM7YjUYLM74Ni8d7Rhl0oEKUZi9C2dX1/xH aPvw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kk11-20020a17090b4a0b00b001c6c499d30csi7732705pjb.162.2022.03.26.12.29.08; Sat, 26 Mar 2022 12:29:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232402AbiCZJ6p (ORCPT + 99 others); Sat, 26 Mar 2022 05:58:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232302AbiCZJ6O (ORCPT ); Sat, 26 Mar 2022 05:58:14 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 838CE1EEE3; Sat, 26 Mar 2022 02:56:38 -0700 (PDT) Received: from kwepemi500009.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4KQZ9N1Pqjz1GDG7; Sat, 26 Mar 2022 17:56:24 +0800 (CST) Received: from kwepemm600016.china.huawei.com (7.193.23.20) by kwepemi500009.china.huawei.com (7.221.188.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Sat, 26 Mar 2022 17:56:36 +0800 Received: from localhost.localdomain (10.67.165.24) by kwepemm600016.china.huawei.com (7.193.23.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Sat, 26 Mar 2022 17:56:35 +0800 From: Guangbin Huang To: , CC: , , , , Subject: [PATCH net 4/6] net: hns3: add netdev reset check for hns3_set_tunable() Date: Sat, 26 Mar 2022 17:51:03 +0800 Message-ID: <20220326095105.54075-5-huangguangbin2@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220326095105.54075-1-huangguangbin2@huawei.com> References: <20220326095105.54075-1-huangguangbin2@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.165.24] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600016.china.huawei.com (7.193.23.20) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hao Chen When pci device reset failed, it does uninit operation and priv->ring is NULL, it causes accessing NULL pointer error. Add netdev reset check for hns3_set_tunable() to fix it. Fixes: 99f6b5fb5f63 ("net: hns3: use bounce buffer when rx page can not be reused") Signed-off-by: Hao Chen Signed-off-by: Guangbin Huang --- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index ae30dbe7ef52..49e7b022caaa 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -1766,9 +1766,6 @@ static int hns3_set_tx_spare_buf_size(struct net_device *netdev, struct hnae3_handle *h = priv->ae_handle; int ret; - if (hns3_nic_resetting(netdev)) - return -EBUSY; - h->kinfo.tx_spare_buf_size = data; ret = hns3_reset_notify(h, HNAE3_DOWN_CLIENT); @@ -1799,6 +1796,11 @@ static int hns3_set_tunable(struct net_device *netdev, struct hnae3_handle *h = priv->ae_handle; int i, ret = 0; + if (hns3_nic_resetting(netdev) || !priv->ring) { + netdev_err(netdev, "failed to set tunable value, dev resetting!"); + return -EBUSY; + } + switch (tuna->id) { case ETHTOOL_TX_COPYBREAK: priv->tx_copybreak = *(u32 *)data; -- 2.33.0