Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3065759pxj; Mon, 17 May 2021 16:54:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqmM16kewy9JvWnSqp3/yA15KPbq7jZ0dQFOMRbNulfwAvH1JIIy6/JKsE59hwBJNPLGHm X-Received: by 2002:a17:906:44c:: with SMTP id e12mr2681598eja.57.1621295662290; Mon, 17 May 2021 16:54:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621295662; cv=none; d=google.com; s=arc-20160816; b=CxZ6fCsfCu+a970uZVim1rgRjZiDn8yIeGIcNIRcVsjxMiKE6R7T0hZNnDQMG2aoGA pNP0dy9a+6lOer2urkWkvVN5J9du79FU4akdsZvSz/hZ3abKHOjD6jey5g4vZ3fVkED3 uopBsne0MwMzUyE4ReB1LWIV55MSvKuJUpFjNpJBbGiP0hNoxQGIwRgUyHJwQKuNklt3 KB4Zf7r7no687zb/+70HUG0QPhIIKRXu8DMPLBhxCvRwrnbAKRTUujB1WFsb50mJZ7Lw H04W0WdHJPv2mZ7PCx12kGNzalqCngpac7FxHIWbhZA+ylxanPq5efR8enJVp++e6XdE LSEA== 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=tzC77ueBRIQLl/iAV4FjgExqCgiA6KCQtLKaIJ98ezY=; b=b2CCxRHoHZ1eIXoyookeIV3k8hc/Mpj/bKWQmJTapcr2tAOUxj4dFia5EFzR3LQ/Wm EaMlfBc64qVPm5kGB3YPuW8dBg5/TcBGwZPE5zWv2EXVLOcDLB6Q1Z7d7Yt/41EB1oET zqvzl/aDNQ7+sz5/+psEi0RUJ5gyE2DjSdLkWmc3y4XGuAXLYeJtFLD9TnuqiqGBnU6f +fT+z1F8Gd7Vv4fekvellOSMY5358t5pRGWwcYkXO8Ic9SEltMbD91XQMCVUB7zUou9J DQvFBJ8qHWvsIdl1z3jp2wHTb5SLtEde2aynJd6ZqGfTshXPEhVpOt9dT4QXWQd58B4y BeDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=olNn3i5V; 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 y16si16481467edc.193.2021.05.17.16.53.58; Mon, 17 May 2021 16:54:22 -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=olNn3i5V; 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 S239457AbhEQOYL (ORCPT + 99 others); Mon, 17 May 2021 10:24:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:36052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235596AbhEQOUf (ORCPT ); Mon, 17 May 2021 10:20:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DA77061448; Mon, 17 May 2021 14:11:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260684; bh=jj4DeBrp/0koXaPIkujDaamW+oKks5g3O8xuE2kySls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=olNn3i5VycHSR73VtC9B4/1XxAAE3/1OueTbT+Qk1xV6XrOLRSaS4Z1AvWRWb7APX aQMSYaOQofzHI6KgJ9Nz+6URIlrWqw6OY7pyMRIK25REnO9yfe7dmH+WNx1iZXheLz BBoPVNbJ4P3RRucOwhEyd3hIqW/HAWlSU18w2QhE= 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.12 194/363] net: hns3: add check for HNS3_NIC_STATE_INITED in hns3_reset_notify_up_enet() Date: Mon, 17 May 2021 16:01:00 +0200 Message-Id: <20210517140309.143715252@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@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 b19df09ffb76..59d4d1e87f65 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -4588,6 +4588,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