From patchwork Sat Nov 25 16:34:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Subbaraya Sundeep X-Patchwork-Id: 169754 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp2040762vqx; Sat, 25 Nov 2023 08:36:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IE6Q1JHryIhANOrBYARpnrMoWBiwBCsA6HUIroxCSwWh7NuuWvogQXVPS+qA3su3u5izsil X-Received: by 2002:a05:6808:1250:b0:3ae:1b21:fab1 with SMTP id o16-20020a056808125000b003ae1b21fab1mr6239778oiv.31.1700930163912; Sat, 25 Nov 2023 08:36:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700930163; cv=none; d=google.com; s=arc-20160816; b=LHpH6x/Y9AIRUV0YWtW3jAYS/K2/aNX1kW0cXNpW70eaN1NmhTjRJZgraDhL9yPb3H I4FqgLALbiOzrOjH4yFuGKnTqZvVeAugpaSaD4OnYOmyAgn0EBC06KhGaF4w7i0v7fZU c+O7BRQeSgUF95+3aUpIM2rB/rhRzeCboWTIQg/zkmSBG0xiD1Y3OR5BlZQ28n0GdZPH rPIra4uxEaRYrvRnEUDMSuu8QdXAkLupD3nFjo+LEsowBGtbqoBoFI7qpFaqQFUEI+Pf rvAPr8BcU91/CwZq8azHT+Vw/4JxO28cYp6JReXEuP8tmMOuBKnlrayp3y25iGToRlhh jF3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=1ewM6MqFrt1Nn4jz3SiK0ncDnmr3if++qJDwehzsdVs=; fh=XH5TQEuSqvRK8iWR7cgl1LZixvfhe5JTwhFT61cZd0M=; b=Il4BrU5NpUVchC3rYVJEGt+5KrFgBCNHaGA1Poop2gu+4oYLf1ZRDICQdyKOY2WTJJ sJ5o71SvJXo0J7KXEnPeN4Qat/jDnbNGX966TwF5mpwE/YMl463HgMppw5JWKmuATlX7 +O1UCsTsfn2ihxg77uL9bJP7y/w4YFof+FvEHB8RiYP0+icchzjGxqKquGZ/o0JGAhDa coCEKhmTLoKWCFDFBiF+pwAadTbgjg6P3evQg0R+z/p1kuvrmY4+kYg6A2tYujE8H703 s58oVRKBUXWjmD43KCcID31CvfVSN7nf4mTAfQua9EPQ1IwWuugbVRTo3ME+FWI7i/8T giTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=bFGjg40a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id x16-20020aa78f10000000b006bc3f09ea09si5916654pfr.26.2023.11.25.08.36.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Nov 2023 08:36:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=bFGjg40a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E19588053C76; Sat, 25 Nov 2023 08:35:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232490AbjKYQfm (ORCPT + 99 others); Sat, 25 Nov 2023 11:35:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232570AbjKYQfV (ORCPT ); Sat, 25 Nov 2023 11:35:21 -0500 Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 356C110D7; Sat, 25 Nov 2023 08:35:12 -0800 (PST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3APGQdxW031342; Sat, 25 Nov 2023 08:35:05 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=pfpt0220; bh=1ewM6MqFrt1Nn4jz3SiK0ncDnmr3if++qJDwehzsdVs=; b=bFGjg40aa74WZm2WvVuWgZEFyX1IgEF+yXniCAhCy7w9EP8Fr2X5xJKm1luGcMFBP5fH zrBhDU1Q+qa1+DB1zC+M3gE8vsGgmqpsyeuWVR9LbJsM2b8Gmvl0PD3grp6gikwqGa3a 6EXzAHA8AjCkr2GDhwlKCiOft0GBTIA0bOmHcLA93Avow0P3VSy+C3qNYO6OMpgT50Pl wz3pblCzTnKTQ2yevTA61O6pQiNT/wyByWPqBOjzAAPZMxEGgWH4mqS8hVxXzozYMU8D 8j7oQ9Wkr8+1RUyKjiMzMxRemO+5s3NuKBWly++msHxWSt/LXlJgDTIgmhDkQysyNQSd Kw== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3ukhauga7b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sat, 25 Nov 2023 08:35:05 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Sat, 25 Nov 2023 08:35:03 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Sat, 25 Nov 2023 08:35:03 -0800 Received: from hyd1358.marvell.com (unknown [10.29.37.11]) by maili.marvell.com (Postfix) with ESMTP id 550DC5C68EA; Sat, 25 Nov 2023 08:35:00 -0800 (PST) From: Subbaraya Sundeep To: , CC: , , , , , , , Subbaraya Sundeep Subject: [PATCH net] octeontx2-af: Check return value of nix_get_nixlf before using nixlf Date: Sat, 25 Nov 2023 22:04:58 +0530 Message-ID: <1700930098-5483-1-git-send-email-sbhatta@marvell.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: Y0GSHBAhKzz3jiJ0plfk7mdBjibKYs-Z X-Proofpoint-GUID: Y0GSHBAhKzz3jiJ0plfk7mdBjibKYs-Z X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-25_16,2023-11-22_01,2023-05-22_02 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sat, 25 Nov 2023 08:35:52 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783554547495789597 X-GMAIL-MSGID: 1783554547495789597 If a NIXLF is not attached to a PF/VF device then nix_get_nixlf function fails and returns proper error code. But npc_get_default_entry_action does not check it and uses garbage value in subsequent calls. Fix this by cheking the return value of nix_get_nixlf. Fixes: 967db3529eca ("octeontx2-af: add support for multicast/promisc packet replication feature") Signed-off-by: Subbaraya Sundeep --- drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c index 16cfc80..f658058 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c @@ -389,7 +389,13 @@ static u64 npc_get_default_entry_action(struct rvu *rvu, struct npc_mcam *mcam, int bank, nixlf, index; /* get ucast entry rule entry index */ - nix_get_nixlf(rvu, pf_func, &nixlf, NULL); + if (nix_get_nixlf(rvu, pf_func, &nixlf, NULL)) { + dev_err(rvu->dev, "%s: nixlf not attached to pcifunc:0x%x\n", + __func__, pf_func); + /* Action 0 is drop */ + return 0; + } + index = npc_get_nixlf_mcam_index(mcam, pf_func, nixlf, NIXLF_UCAST_ENTRY); bank = npc_get_bank(mcam, index);