From patchwork Wed Nov 29 05:28:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Subbaraya Sundeep X-Patchwork-Id: 171063 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp133517vqn; Tue, 28 Nov 2023 21:28:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFeu5sA06gxm9MONM0eDkFpwYcubrdIWl1xuQUsFMbh65Jfa0CAgpGQsL5fxKNmffB2KhXK X-Received: by 2002:a17:90b:4b4b:b0:285:b928:e2e4 with SMTP id mi11-20020a17090b4b4b00b00285b928e2e4mr10354297pjb.30.1701235721693; Tue, 28 Nov 2023 21:28:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701235721; cv=none; d=google.com; s=arc-20160816; b=lcx9Cmz61zUaw6EHZitZM9RHc6p1xWrvN6x8vOr5eK9Zx2G6qWtK8n9c9RiYvezkLR s4C1hlANahT1yzZmV5DoVjAzRilQp9XQJgRu9yCHI7cXPrSR/xncitziko5zo+59kkKg DgEKJh7fYbGFFDDBLdABYqBt05RlcsCBxdearti7K5QCH8I0CvckBmlpwzfdVg25nK3/ /S6qzwcJ2g6LJ/kZJEVzMfeFcO/ixL0qPb306ZomuC1TKicm3WiLoUqmLL9GTnsfFhmy vz3SXawv7wtvhux6r0w+DWotasR0BALU09+KWkV6FII8JwqokrSs2G62+FtCzy2QRvAI pV9w== 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=h3G+JKyrvGTY4IDHl3QNCgCSRyv27XxZoC2f2MnIcCg=; b=IE242MRepVfffYY8+9yNzShKvHeUqw/AJjgVtmaivkvhqmqN7FiTRWlLP9N9O9J5Xa mppoV+WDozXrSHO6/MYPh4uYP1IWUBXAds2hgWieBi6ZuHWhRfKysbDQUL7d3R+2tv2s X0bjYlX0txu9HtPFho5vwcyTidY5ddCq9RKqNH17oLFh6m2oX2wUx5hhW8FhsbqdCmqu KX9BMnzhtMPV21+bnVxHhoyR5Ep9wnaZI8S+lltdV6Ds0np41+S3RYB0FMsJltcpSBY+ Qs9EEaolJ9H5eBO2oDN2QqbQ+gK0EoV6yVJMvip/Z9dMMXPsQfBgJX+dRHH6Dy7dQEB2 vJUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=inLIu5x8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id h6-20020a17090a710600b0028589f571fbsi585892pjk.148.2023.11.28.21.28.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 21:28:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=inLIu5x8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 688AA80C056E; Tue, 28 Nov 2023 21:28:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229834AbjK2F2b (ORCPT + 99 others); Wed, 29 Nov 2023 00:28:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229563AbjK2F2b (ORCPT ); Wed, 29 Nov 2023 00:28:31 -0500 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A91B19A; Tue, 28 Nov 2023 21:28:37 -0800 (PST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3ASIdt6r021079; Tue, 28 Nov 2023 21:28:32 -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=inLIu5x8poU/JJLW8MF6VMpPAhEVAc1dA1pmaMD4j3wgFnzAheO27nqm+sT8Nt9OYLDW nWnWmu0A96+ebIq9CKQ6dJRcfLQ24oyT8Mfc9IlFxAnpfEOf2KaHNQaRJskEdNOIkJRH UsA2io64e2X/80Oklb/uHHTbp28tGJJ6mvA9oqJuODZIHJaVve0QsRWwmn6S7iZoTRTV C3SPDGfENuJnnVchZ/qpDqb93qfwPHa8/xCfjPt1n2JFDUmamXRJfGpQasPHYY4VsSMH N65MuBjMLlGBbnwhTZjtp6JQ1hjIbvdQVvRQg9CYMPRoT0ujnls1DUynRHUuFDVmGxBi nw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3unn86a1jc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 28 Nov 2023 21:28:31 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Tue, 28 Nov 2023 21:28:30 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Tue, 28 Nov 2023 21:28:30 -0800 Received: from hyd1358.marvell.com (unknown [10.29.37.11]) by maili.marvell.com (Postfix) with ESMTP id 1BE3D3F7043; Tue, 28 Nov 2023 21:28:25 -0800 (PST) From: Subbaraya Sundeep To: , CC: , , , , , , , , , , Subbaraya Sundeep Subject: [PATCH v2 net] octeontx2-af: Check return value of nix_get_nixlf before using nixlf Date: Wed, 29 Nov 2023 10:58:23 +0530 Message-ID: <1701235703-22690-1-git-send-email-sbhatta@marvell.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: pdscyTL9rRvbjJzcLYViIVRJFf9LGElg X-Proofpoint-GUID: pdscyTL9rRvbjJzcLYViIVRJFf9LGElg X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-29_02,2023-11-27_01,2023-05-22_02 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Tue, 28 Nov 2023 21:28:40 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783874947629453894 X-GMAIL-MSGID: 1783874947629453894 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);