From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B121EB64D7 for ; Mon, 26 Jun 2023 21:54:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231622AbjFZVyL (ORCPT ); Mon, 26 Jun 2023 17:54:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231623AbjFZVxU (ORCPT ); Mon, 26 Jun 2023 17:53:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB4A02733; Mon, 26 Jun 2023 14:51:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 30CBF60FA9; Mon, 26 Jun 2023 21:51:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70B4EC433C0; Mon, 26 Jun 2023 21:51:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687816278; bh=JkrBeUMrDfM/8+f3u/o+VOv6s31nOY8jRN3Zy1lqcbY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PUsYcgsVBObtxCT7F30K2DjqOltjU40ZC8ZQZ8zk/bDED4cPzyxxn3jIZDq7QvnHI t/CtjjeEVkDMy5gKUdprhZ687qdGTpXSWO6DShAV8iM/2rgAg65Qe1u+l+87LhtuT3 ClLIRSnwjnxcCngYcC6jXYy169wDVAmHkgXUvmzBwv1qTJdDaDSWULFFOM6RXZK5KJ 56bj3Kw6ijWBAuzQXBPZJP9g/hF5ExnFqBhz0rKe9w6V/rJz1sZ9j8OfbrbIEvkYpM dlqApxxYJ4TJHs2WTit/cufUmOcsPIlZrvJU014G76i1fnxQouf8AM+3OeKmOIIFi0 JvNeitDwrIHpw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: David Christensen , Sridhar Samudrala , "David S . Miller" , Sasha Levin , aelior@marvell.com, skalluru@marvell.com, manishc@marvell.com, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 2/6] bnx2x: fix page fault following EEH recovery Date: Mon, 26 Jun 2023 17:51:12 -0400 Message-Id: <20230626215116.179581-2-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230626215116.179581-1-sashal@kernel.org> References: <20230626215116.179581-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.4.248 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: David Christensen [ Upstream commit 7ebe4eda4265642859507d1b3ca330d8c196cfe5 ] In the last step of the EEH recovery process, the EEH driver calls into bnx2x_io_resume() to re-initialize the NIC hardware via the function bnx2x_nic_load(). If an error occurs during bnx2x_nic_load(), OS and hardware resources are released and an error code is returned to the caller. When called from bnx2x_io_resume(), the return code is ignored and the network interface is brought up unconditionally. Later attempts to send a packet via this interface result in a page fault due to a null pointer reference. This patch checks the return code of bnx2x_nic_load(), prints an error message if necessary, and does not enable the interface. Signed-off-by: David Christensen Reviewed-by: Sridhar Samudrala Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index b5f58c62e7d20..211fbc8f75712 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -14426,11 +14426,16 @@ static void bnx2x_io_resume(struct pci_dev *pdev) bp->fw_seq = SHMEM_RD(bp, func_mb[BP_FW_MB_IDX(bp)].drv_mb_header) & DRV_MSG_SEQ_NUMBER_MASK; - if (netif_running(dev)) - bnx2x_nic_load(bp, LOAD_NORMAL); + if (netif_running(dev)) { + if (bnx2x_nic_load(bp, LOAD_NORMAL)) { + netdev_err(bp->dev, "Error during driver initialization, try unloading/reloading the driver\n"); + goto done; + } + } netif_device_attach(dev); +done: rtnl_unlock(); } -- 2.39.2