Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp777483rwl; Fri, 7 Apr 2023 05:28:36 -0700 (PDT) X-Google-Smtp-Source: AKy350by2Yja2fKdLeXe9XD1Q1iuHsYPvrylqBxkfcf4VGPYOUsuAJYvDKipYjHOYW36LEaGsF4k X-Received: by 2002:a17:902:e541:b0:1a5:1748:7bc with SMTP id n1-20020a170902e54100b001a5174807bcmr1388122plf.11.1680870516460; Fri, 07 Apr 2023 05:28:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680870516; cv=none; d=google.com; s=arc-20160816; b=oKCfBkrKHZkayGGlJCtJ+fgMi452e4UrmMsuGK3/ZOH2xd1cs9Wt3xmaDklR7dnJiX MbHqm0GkKWUJ0j1lqeDPuVKfhgz7R4Fkm++flj6bDo4ydIVNIXHE2U2iAwnnm68EWFyG PkQzMi/EonhY9U1dFOvYJP5eFbPWFkP8ZGFNpg99vVFMvN3VOom55kZ0TkHLmaqwrz1y XJSn1CXlm3MBj3ziKxTZDF1mkjNF0dB7fs5++bQ0x4p4ARLoJONwj82B4hPHHNUdqHT7 Bshd33mIjrZmuGm+DHfFJGV8Q7k1e9y/HbCzPjF0FmC8lVYWLUCBXIePCU4lnn53phHX qaBA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/1EraJ/KOS82xadi014qOEu9vIJ5vyi/xvCLp1ys0n4=; b=ZVGl+SW+8NcgiQbsEoDZge3HJtVF1LK4E4weP1Hcrd43PHuL37dgpUu7xaNeTiGVat 3O2i6DWAIgk6rIBXCO7c+o1EldYKd7lGyXYxbCM00yY9mIMAIP/QQsoDBusF8ZOn1ikx gsQc7siea2MDaahZdDF5zngD8/YP0lI5SNr9IfZ3srxxhmzRQPi05jKJfVA6HmEX5Bya tvJyWrHEvt5PV5N3NOt1LUuwrUYcP7bCGXCiZnM6p/NLSVVgz9DYPJtHeqQVFuQsjLDX dl6Hwz1h2Jpy2VU9lHgEgZuRx7QJqECDeW/Yguu3jm163muWxobcRil1p/oyEjMZyK6A VHCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=i2dL+p+a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 64-20020a630443000000b00502e76a516csi3578207pge.500.2023.04.07.05.28.25; Fri, 07 Apr 2023 05:28:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=i2dL+p+a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240752AbjDGMYW (ORCPT + 99 others); Fri, 7 Apr 2023 08:24:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240723AbjDGMYP (ORCPT ); Fri, 7 Apr 2023 08:24:15 -0400 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84039AD32; Fri, 7 Apr 2023 05:24:14 -0700 (PDT) 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 337AwmMb000622; Fri, 7 Apr 2023 05:24:08 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=/1EraJ/KOS82xadi014qOEu9vIJ5vyi/xvCLp1ys0n4=; b=i2dL+p+a2hwY9hD+mvMmueS4VLsVB9+VF4V9Wq7WYvuYaBONPQfMBpfoQjEsKo+RuFfQ 4HPXtCuHSjGikhZ5hiydmN0AkYugBJc2ZAcQZaF3D5oL1zdfbbn0QGlNdTunONXlhK5p lnIV8cnu9QaEIpWuCgyb2HAZNAp7EspNwCXf2cURzCuZW7xSHZVndVcvLVfH6paQlWgD s5n9qS0lGOTs1FSJPLnMKRt/eIXCSKiw5fCeuO4WOq3AubqmpJvCirkFEAHty8XhbDJZ /iZScuRdZW9aTeWtg0MDLc6inT97/nsNoImEPZjjAjfkQF2r1ZQmeo3YmGaFKoAf5mNa Dg== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3pthvw88q9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 07 Apr 2023 05:24:08 -0700 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; Fri, 7 Apr 2023 05:24:07 -0700 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; Fri, 7 Apr 2023 05:24:06 -0700 Received: from hyd1425.marvell.com (unknown [10.29.37.83]) by maili.marvell.com (Postfix) with ESMTP id C2EE33F7064; Fri, 7 Apr 2023 05:24:02 -0700 (PDT) From: Sai Krishna To: , , , , , , , , , , , , CC: Sai Krishna Subject: [net PATCH v2 3/7] octeontx2-af: Add validation for lmac type Date: Fri, 7 Apr 2023 17:53:40 +0530 Message-ID: <20230407122344.4059-4-saikrishnag@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230407122344.4059-1-saikrishnag@marvell.com> References: <20230407122344.4059-1-saikrishnag@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: ZFoNIYd5WKTaD56V4R7BOvRRoLKsCAxj X-Proofpoint-GUID: ZFoNIYd5WKTaD56V4R7BOvRRoLKsCAxj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-07_08,2023-04-06_03,2023-02-09_01 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 From: Hariprasad Kelam Upon physical link change, firmware reports to the kernel about the change along with the details like speed, lmac_type_id, etc. Kernel derives lmac_type based on lmac_type_id received from firmware. In a few scenarios, firmware returns an invalid lmac_type_id, which is resulting in below kernel panic. This patch adds the missing validation of the lmac_type_id field. Internal error: Oops: 96000005 [#1] PREEMPT SMP [ 35.321595] Modules linked in: [ 35.328982] CPU: 0 PID: 31 Comm: kworker/0:1 Not tainted 5.4.210-g2e3169d8e1bc-dirty #17 [ 35.337014] Hardware name: Marvell CN103XX board (DT) [ 35.344297] Workqueue: events work_for_cpu_fn [ 35.352730] pstate: 40400089 (nZcv daIf +PAN -UAO) [ 35.360267] pc : strncpy+0x10/0x30 [ 35.366595] lr : cgx_link_change_handler+0x90/0x180 Fixes: 61071a871ea6 ("octeontx2-af: Forward CGX link notifications to PFs") Signed-off-by: Hariprasad Kelam Signed-off-by: Sunil Kovvuri Goutham Signed-off-by: Sai Krishna drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c index 724df6398bbe..bd77152bb8d7 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c @@ -1231,6 +1231,14 @@ static inline void link_status_user_format(u64 lstat, linfo->an = FIELD_GET(RESP_LINKSTAT_AN, lstat); linfo->fec = FIELD_GET(RESP_LINKSTAT_FEC, lstat); linfo->lmac_type_id = FIELD_GET(RESP_LINKSTAT_LMAC_TYPE, lstat); + + if (linfo->lmac_type_id >= LMAC_MODE_MAX) { + dev_err(&cgx->pdev->dev, "Unknown lmac_type_id %d reported by firmware on cgx port%d:%d", + linfo->lmac_type_id, cgx->cgx_id, lmac_id); + strncpy(linfo->lmac_type, "Unknown", LMACTYPE_STR_LEN - 1); + return; + } + lmac_string = cgx_lmactype_string[linfo->lmac_type_id]; strncpy(linfo->lmac_type, lmac_string, LMACTYPE_STR_LEN - 1); } -- 2.25.1