Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp701139pxb; Tue, 5 Apr 2022 19:23:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3nyP2vPPNGcLWSfuuJkes+BVZqWhLUQVlJYhzfHrpWq6EPDR/kB7tcgjbpFGLGUuNQSVa X-Received: by 2002:a17:90a:4882:b0:1c5:f4e2:989a with SMTP id b2-20020a17090a488200b001c5f4e2989amr7525122pjh.160.1649211797246; Tue, 05 Apr 2022 19:23:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649211797; cv=none; d=google.com; s=arc-20160816; b=hFlHXhlYgQkEUF8cbnz2WR16G0Wf2oBBGGR3zQTP9aZyfQofRXCDJXsZxkQeKyifqD 4+WzVrKxPSQoq5yOJ5wIjrfzzRTAkW3qnM17BQaDLtR/fwGZCp0mlb8c+qCQr6q7STN+ oy/5GkITQuSAAEFcsVBMyZ2eGTB2fueQLGb/7z68YY0qyT22sAWZUQjJs0quSjKowAF5 FIR0eDHZNij3fQzgF8WKcbgWAYvTzdhToddpC+S55S8BgwS0ui172GIZJsYag0C4vEMy VhS2KtWweE7TGjTuywFQ0opAOSf7H0NRKdN58hXAmnmsGPzRHOCUWpQ2XEJ4yiwtnFtC Qf5g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CmqLXujb7be3pElvy6exLoEu0kjqHxYIqvRp1dAqxx4=; b=bIVhAGvaB+Ui/+pMNI2RZFV5tcRR/Yh/VFr61h1KQ83wuHAtAa8FIzBSVgqcli+yZK Zmuba9CzGcsGkn81NFojITxHKbOb4p/FSuNWDDQjMZ7sI0SG/RjjdV0LalaVuGYZmLrT wPNQRQduF4CpJR/F+QSM/Yjj61zpmH2HyNIT3iTO4Xnbmbkho7JYboaF/FeB6/1KyYko dl9CQwUTVgX/S7cUEE7h3LdhV/hOfl83HI5ZbDA32g+WSaRvYXwlqTkAnWYj3zAuF/Q2 M8AiIZQaaVNstWH/KFk7ySE4Ay7/HGgqTy77yYcIwgrcFBwDBIwoX9a/44YXVF5ozVBc zgFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wvaKmJf2; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t9-20020a170902b20900b00153b2d1646bsi13641019plr.115.2022.04.05.19.23.02; Tue, 05 Apr 2022 19:23:17 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wvaKmJf2; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347904AbiDEJ2m (ORCPT + 99 others); Tue, 5 Apr 2022 05:28:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239559AbiDEIUO (ORCPT ); Tue, 5 Apr 2022 04:20:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA71C636C; Tue, 5 Apr 2022 01:16:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 67CDA60B0F; Tue, 5 Apr 2022 08:16:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73072C385A0; Tue, 5 Apr 2022 08:16:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649146588; bh=wnO/W1VKyil+x2hzjyqb7HU+6IrSK8quU5k/yT2LCuw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wvaKmJf2zAdbVu3uA/1rIrK+fOFrj8Q2rA64J7IY7lBF24nXT1gUPR6/YFPQJyRqn 51juS3ivYDWDlblKJvX/EapvRdBpYdsLGXytPDvOGiJKvynZSgWGL+tGrnOZMuZuDK IiDD3xRRAYOX/8jGin7vbqdcHTTQbYTWublCre08= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hao Chen , Guangbin Huang , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 0818/1126] net: hns3: add netdev reset check for hns3_set_tunable() Date: Tue, 5 Apr 2022 09:26:05 +0200 Message-Id: <20220405070431.574524114@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 [ Upstream commit f5cd60169f981ca737c9e49c446506dfafc90a35 ] 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- 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 7591772c9a6b..1f6d6faeec24 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -1764,9 +1764,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); @@ -1797,6 +1794,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.34.1