Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp363300rwd; Wed, 7 Jun 2023 00:37:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5zePCISqTKJkLDAW3SQMqJtnAaSCI3W36MAVsprRodX1HJZa+S2vWuj/OEUDj3HVapkhEJ X-Received: by 2002:a92:d411:0:b0:33b:7e4:167a with SMTP id q17-20020a92d411000000b0033b07e4167amr7380683ilm.15.1686123412509; Wed, 07 Jun 2023 00:36:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686123412; cv=none; d=google.com; s=arc-20160816; b=qp3Yn19DJNaDdrn1v5C5uTpXV5g1Ss8vz3k2f6zeZ9Rs7H9QnUEbkqtW/5S9jEBxpp iTlLpHdDgzu9E0pCIQD17qekNZdXQw/epFY3G7d7ZmB2DK41ERbpfOi9QW+owT7RPci3 fXRhZ6T2J+Kg2LzkFdg5Usn3/0SDkl2VRYw49eGaZjsWNbKLviBtyxB/GD9I8vuy057c 3HX1O/4pkWEazpEWw1na5MV8TxPjzOzTxiv6tjWTplnmh2o830AjTJNl6k0M2E2P/Y0H vH9xXxGbAtmhlSSRyhs0ikromQQ8fUkVc8xD8JzVqnGBY16l75woX8sI90W/8KX4TRf/ wrag== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=k923a7Oxn1k2haeRkq4asJ9KrNimQZa4Ue+wkrhnX9g=; b=wAf+W6uYwOr5iZiqvgX3n7a1LJg9bBLSPuswag+xXN0uZqH6VBsjDcNaC1PZ7nIxAQ 0y/1Yby1iqVOq8Or2UzGaz1uuBqdlB8HWyTq9CQSd8eVZ9Ajzyss5jTdgmiX/i0HaSKS uoC/yNsjkCD3alo9x7PiEtrlXsKruYGTUJ+VnhpA+P5iURmeYYksw0p9V3928yyhrrNh qBNynBEK6l1FNKZb3j90fe14515fkDb964aJfPai4SkFErS6jQyTQUOKb21ZsndwqpQl HDkLCvQxK/htt5YKohkKObmK+d30D3sGlIMSNCfNplJnikKBriAtVXTHp2iACYkJUdeM 0L9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=XeAGaidR; 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 l188-20020a633ec5000000b00524eef20da6si8592055pga.642.2023.06.07.00.36.39; Wed, 07 Jun 2023 00:36:52 -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=XeAGaidR; 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 S238605AbjFGHDX (ORCPT + 99 others); Wed, 7 Jun 2023 03:03:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238205AbjFGHDV (ORCPT ); Wed, 7 Jun 2023 03:03:21 -0400 Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6ED321732; Wed, 7 Jun 2023 00:03:20 -0700 (PDT) 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 3575KDC2022645; Wed, 7 Jun 2023 00:03:06 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=k923a7Oxn1k2haeRkq4asJ9KrNimQZa4Ue+wkrhnX9g=; b=XeAGaidRrB/iL3X2hENXzlCCevc93bUGD0ulGN9z5QFWYz3qUf7K31sqDfh7Fy2z9YzZ 9kyvy+AW3B+1qxcCCnbOql3gnwVU4OvwwBnlZMdvXYoC8VYEZOxChTQvQPqqMqAK9acC wuTF3ZCTMqTVY7LnGXdqkprf19t7mzkl03ds99uBLGZOarg2RGhvOFkY1QnovttNxBg/ W1ebfx30wWu7ZtG4TdPVYWNaYuQIrUSg+FDMKUidH14HHjhQHdRGuptj5hEopASBqIKa +ntYcv2tJSxY8vVeLpJYFZD1JF4femYaYX9eyVuj/QKY1fwbj0x10mh3rJir2a2h25NF Ow== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3r2a759tra-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 07 Jun 2023 00:03:05 -0700 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; Wed, 7 Jun 2023 00:03:03 -0700 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; Wed, 7 Jun 2023 00:03:03 -0700 Received: from hyd1425.marvell.com (unknown [10.29.37.83]) by maili.marvell.com (Postfix) with ESMTP id 03AC53F708E; Wed, 7 Jun 2023 00:03:00 -0700 (PDT) From: Sai Krishna To: , , , , , , , CC: Sai Krishna , Naveen Mamindlapalli Subject: [net PATCH] octeontx2-af: Fix pointer dereference before sanity check Date: Wed, 7 Jun 2023 12:32:55 +0530 Message-ID: <20230607070255.2013980-1-saikrishnag@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: wMSWW6VGaA-pXum6hlxiUEb3zaKmJBgv X-Proofpoint-GUID: wMSWW6VGaA-pXum6hlxiUEb3zaKmJBgv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-07_04,2023-06-06_02,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,URIBL_BLOCKED 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 PTP pointer is being dereferenced before NULL, error check. Fixed the same to avoid NULL dereference and smatch checker warning. Fixes: 2ef4e45d99b1 ("octeontx2-af: Add PTP PPS Errata workaround on CN10K silicon") Signed-off-by: Sai Krishna Signed-off-by: Naveen Mamindlapalli --- drivers/net/ethernet/marvell/octeontx2/af/ptp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/ptp.c b/drivers/net/ethernet/marvell/octeontx2/af/ptp.c index 3411e2e47d46..6a7dfb181fa8 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/ptp.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/ptp.c @@ -449,12 +449,12 @@ static void ptp_remove(struct pci_dev *pdev) struct ptp *ptp = pci_get_drvdata(pdev); u64 clock_cfg; - if (cn10k_ptp_errata(ptp) && hrtimer_active(&ptp->hrtimer)) - hrtimer_cancel(&ptp->hrtimer); - if (IS_ERR_OR_NULL(ptp)) return; + if (cn10k_ptp_errata(ptp) && hrtimer_active(&ptp->hrtimer)) + hrtimer_cancel(&ptp->hrtimer); + /* Disable PTP clock */ clock_cfg = readq(ptp->reg_base + PTP_CLOCK_CFG); clock_cfg &= ~PTP_CLOCK_CFG_PTP_EN; -- 2.25.1