From patchwork Wed Jun 7 07:02:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sai Krishna Gajula X-Patchwork-Id: 104281 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp69733vqr; Wed, 7 Jun 2023 00:23:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4BSs521DX/CqciwbasoB6xR+ZwGifIvpJRF5kjCHPFe40H8OqPGeqOJFZetOTejy9myTOh X-Received: by 2002:a05:6359:2a0:b0:129:7bf:eeca with SMTP id ek32-20020a05635902a000b0012907bfeecamr1474453rwb.21.1686122637042; Wed, 07 Jun 2023 00:23:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686122637; cv=none; d=google.com; s=arc-20160816; b=lbiI7mmkQO7Ab+8LOzJDFR2ENMbI0pRBJgAaMpHY0JZYcb0GF/0Yvpq1FbtzN/CVDd g/vW4c8LH0zPfeu7MxrhuzpOLKYpQp186ZsbRc/AX/IT5WmP8DDkXDWjqLJHLIeA16Gh bnkcSkWJuSfDyk9238qPpxus75PyiB227BDOjh0jvlzXhR8aEY5kIDHegVFprYcvAvv7 DJlovwld2f/DaMy5wegiBvBrhPzUpASc1b2LcGNdsId2iLrKAALX+1sVzOpbg0q+KzUa W9LB7ZbuBiNzHv6QNK2rNXzuFgpIUEaLUv1GK0zNLTnJyuYOKBgJs0Q8Fy7+KroM73vj fU6w== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y186-20020a638ac3000000b0054507258ce0si251463pgd.234.2023.06.07.00.23.44; Wed, 07 Jun 2023 00:23:57 -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 S238606AbjFGHDY (ORCPT + 99 others); Wed, 7 Jun 2023 03:03:24 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768027730270332438?= X-GMAIL-MSGID: =?utf-8?q?1768027730270332438?= 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 Reviewed-by: Maciej Fijalkowski --- 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;