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 7ECD1C4332F for ; Mon, 13 Dec 2021 10:08:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242088AbhLMKHH (ORCPT ); Mon, 13 Dec 2021 05:07:07 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:45350 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239965AbhLMJ7D (ORCPT ); Mon, 13 Dec 2021 04:59:03 -0500 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 ams.source.kernel.org (Postfix) with ESMTPS id 3AE3FB80E19; Mon, 13 Dec 2021 09:59:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45940C34600; Mon, 13 Dec 2021 09:59:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1639389540; bh=BsTAnJceb6nl69zlrAqXY2nKun49rSGHx6DmPhVI1xY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KMu7KgPzDwFyQSLDydMpkF6jJafHlFrSdOtA7vPI46rtUKz5cqc3WYUk/ZfmueWCI KPKyfe81wwoc2LnY3iyQsjtO+4tqVVtbwWMS4i6xB4xHR+Y/Bj3RUNCcpEjPBgiwxR OB2IXz8i5iaZoOWQD8xLLolq+zCzf9PUIGiR8HFA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sylwester Dziedziuch , Norbert Zulinski , Mateusz Palczewski , Gurucharan G , Tony Nguyen Subject: [PATCH 5.15 123/171] i40e: Fix NULL pointer dereference in i40e_dbg_dump_desc Date: Mon, 13 Dec 2021 10:30:38 +0100 Message-Id: <20211213092949.198364277@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211213092945.091487407@linuxfoundation.org> References: <20211213092945.091487407@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: Norbert Zulinski commit 23ec111bf3549aae37140330c31a16abfc172421 upstream. When trying to dump VFs VSI RX/TX descriptors using debugfs there was a crash due to NULL pointer dereference in i40e_dbg_dump_desc. Added a check to i40e_dbg_dump_desc that checks if VSI type is correct for dumping RX/TX descriptors. Fixes: 02e9c290814c ("i40e: debugfs interface") Signed-off-by: Sylwester Dziedziuch Signed-off-by: Norbert Zulinski Signed-off-by: Mateusz Palczewski Tested-by: Gurucharan G Signed-off-by: Tony Nguyen Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/intel/i40e/i40e_debugfs.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c +++ b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c @@ -553,6 +553,14 @@ static void i40e_dbg_dump_desc(int cnt, dev_info(&pf->pdev->dev, "vsi %d not found\n", vsi_seid); return; } + if (vsi->type != I40E_VSI_MAIN && + vsi->type != I40E_VSI_FDIR && + vsi->type != I40E_VSI_VMDQ2) { + dev_info(&pf->pdev->dev, + "vsi %d type %d descriptor rings not available\n", + vsi_seid, vsi->type); + return; + } if (type == RING_TYPE_XDP && !i40e_enabled_xdp_vsi(vsi)) { dev_info(&pf->pdev->dev, "XDP not enabled on VSI %d\n", vsi_seid); return;