Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp477053pxj; Tue, 18 May 2021 07:35:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwb25HKoSn7XVbGpnujufewp+aRSh60KPlsyaP6DfNe+JoKcJowfJn/swpnruB53BLqu9K+ X-Received: by 2002:a17:906:a1cb:: with SMTP id bx11mr6557000ejb.115.1621348554385; Tue, 18 May 2021 07:35:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621348554; cv=none; d=google.com; s=arc-20160816; b=y2aUbfnXwxm5GVdU4Xzx4txuZhFxMHbGmQ3AOl8cE7W812gCljlJcrLeO7FcRiXLuI ybbvBSKrHglgoeAjs9oBG+n3jfNMPoenpCe+YgSml2YoCeNVDHHSRuDo9uWR9VVREEZy vFaWZvfwbmBv7KTDOvZ7BRe2Clq+7Rt8Xe/GM2eYnezNcXVyZoIrswrQdMCMyfdng8US jpOq+2UtpKwIcol7Iz2pbimJUf4c0r7adY/cBqfJKconAAIjEeAt8nltpe9qepKmMxvO 1F3fTuBTvabpiCJArBDWdRVulCMAMu6m/l4B4Hfe1ww35yek4uRzTIAzZXwd3YGfVHld Ry2Q== 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=vVcM+F9q5/WYWgFn5r7zVLg2EVECGPhT4RDvSEF9IBM=; b=XSl6OxgSrUvRb7GHNsN9mVMNi1BadQBBY7TIAiQPVFBTbfkSX+dOB/F6uBOnbFitlr 7NGWyH80qNGnYFJqwckHlfYLyLHGmuoA0LOk8FfdRUA7pf8IahKLAPTqOwtJlZ75oWVB ZAeWQyYvOx1dZS6QatTI1CM6bgrP5zqD6UWMRddiVb3bO3sLhx06XE7s+NNg7bFNxqkp CPZaYj9wHVP3FhjvPuhvZo21ZzecMiysZ9eLgli3XftVZ/8XiekBWxzHqx4UDVMOuQ3f kkGbeVCO4J99UID6w1MkXAULeu9ZdL15UQr/vE8ZgkrcLpDJNPlOXsPpr33LD0cWim8o UarQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gl4aLcuT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y65si8968668ede.79.2021.05.18.07.35.05; Tue, 18 May 2021 07:35:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gl4aLcuT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1344646AbhEQPpK (ORCPT + 99 others); Mon, 17 May 2021 11:45:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:57350 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245452AbhEQP3a (ORCPT ); Mon, 17 May 2021 11:29:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C953461CC0; Mon, 17 May 2021 14:37:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262256; bh=V3UgJob7QLo8qx5KzW4LjjwSxD+CL6EpjDBYIrZhTo4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gl4aLcuTelEdG50GnBvdXxcFGT/wyacTdX1rADw2q528oanuVKt5GEYtg1sb35kie xfnYHVug+0k22Ml7YaWPkmrCiiDcIKyHOoG/qNNkp+jQ+LPAkePP3hW98E+ZMbsFAX N1UDk5F8w+xO0ovT8sUm33P7jljzqyHeTgOj1new= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jian Shen , Huazhong Tan , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 147/289] net: hns3: add check for HNS3_NIC_STATE_INITED in hns3_reset_notify_up_enet() Date: Mon, 17 May 2021 16:01:12 +0200 Message-Id: <20210517140310.098039183@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jian Shen [ Upstream commit b4047aac4ec1066bab6c71950623746d7bcf7154 ] In some cases, the device is not initialized because reset failed. If another task calls hns3_reset_notify_up_enet() before reset retry, it will cause an error since uninitialized pointer access. So add check for HNS3_NIC_STATE_INITED before calling hns3_nic_net_open() in hns3_reset_notify_up_enet(). Fixes: bb6b94a896d4 ("net: hns3: Add reset interface implementation in client") Signed-off-by: Jian Shen Signed-off-by: Huazhong Tan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 051598341968..6066cb0a5abb 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -4426,6 +4426,11 @@ static int hns3_reset_notify_up_enet(struct hnae3_handle *handle) struct hns3_nic_priv *priv = netdev_priv(kinfo->netdev); int ret = 0; + if (!test_bit(HNS3_NIC_STATE_INITED, &priv->state)) { + netdev_err(kinfo->netdev, "device is not initialized yet\n"); + return -EFAULT; + } + clear_bit(HNS3_NIC_STATE_RESETTING, &priv->state); if (netif_running(kinfo->netdev)) { -- 2.30.2