Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3597267pxv; Mon, 28 Jun 2021 08:14:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXW7nLArfpppJo6ZrT1ToRRTelB65exufXmIAHKifwerFU+PK1T/bCNTHv6ux6WYToetd9 X-Received: by 2002:a17:907:20f7:: with SMTP id rh23mr24460281ejb.64.1624893268529; Mon, 28 Jun 2021 08:14:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624893268; cv=none; d=google.com; s=arc-20160816; b=JBEfbc17NgAUi71GHzKFHMw/NtU0vDVGb8cveCjwffIbrkfItw2v9INxdEP0XGwAoQ vQNHjKaK/eCVJqrVjhqq4fvzLxxTQGYLe2/gmFX7msp6WEnbt1+lmrBZ8+gdn1bcKJTX 0KjRNF8I2/7pR7fbfGzvKn7OIuH4CRgvPltyzq9AhGSOVo0xLui2QYYUtQLRuwEbVMDx qRn03ZxX7rOMHUS9W3hIxJGdHkDgx+I8RltHT/Xq2U3PPUUVEJAJsj1LW54ih9i0dHmS bS2xoqsGVTJV8XCgIhlY8OfUzihCkxlERmdCNe53TxBwl+gF10obtBfDVUAnjJUJzZzK EaYg== 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=RFPjKAsMbCRimhatdvPsSgdd1z3IPl7PYIc6QhMFeRk=; b=kS/1gdhtac7aGtlfu0rRQ73+KWY3iMUdEwX871i0Uf4Tub79FryR9N2TsdlnVq/7Qb r+a8dLY9PMSMVEta1w29nwm2opBxpaXPh3r54fPLbfy4V3rhHRmfuy5+MyNIvD/WDrVA sVetDTDwHKiMS2ulj0KIOxiagIJIK5RrjCnHKOCgSXLsHdbesCRPvYKZDHwYK1iI2wjt MskixPlzhNCre78uJXFiuJ8+0ZcazR1btl9B+/02DKzN03i5ZeNA8BFofvA05bSyVjzb iAgQaSWPr5DyE8n0J8NcGy7tTAjwvemOE8ESmr6lJLPn1rj4tLb2YT0OYkCS0CEDUo5y OygQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="dIxXCB/a"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b7si14181626ejl.450.2021.06.28.08.13.58; Mon, 28 Jun 2021 08:14:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="dIxXCB/a"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237290AbhF1POS (ORCPT + 99 others); Mon, 28 Jun 2021 11:14:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:56020 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235169AbhF1Owy (ORCPT ); Mon, 28 Jun 2021 10:52:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AFA0861D36; Mon, 28 Jun 2021 14:37:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624891040; bh=dOSQMVzC1+Qb8BEXXGvXIo4vTwaWNEYHD9IU7BlNKP8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dIxXCB/a+nIY1xGNDfEGjO1QKBx/egH6YmHnVXI3p7xjzF/uFq6O0UIgUdxogQnUy hPYPmAOIOdA39ypYHw/tZEr2Er4eKkySJltunfVKrCcrwqwTSdUwAkHBK07pgG8AuH cIeopuu/bMGKsWf5LPMtEy1YM+qGpRRoM017f6vM3G6PdXdt697m0LhNGNHpRh0uYW 8t41dCbZWG0qNsYeAvr9uss2xP/K7L3fcMvrBg5lA21Sl5GiT8tBaX17vO65CT9oiz sRZAXUv/B/vET4DHoxdVvpRsd33JrSuqjsHccgNOM2ZRr7m8uCppkai01qgySF20vr woX9ghthUl8bQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Fugang Duan , Joakim Zhang , "David S . Miller" , Greg Kroah-Hartman Subject: [PATCH 4.14 58/88] net: fec_ptp: add clock rate zero check Date: Mon, 28 Jun 2021 10:35:58 -0400 Message-Id: <20210628143628.33342-59-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210628143628.33342-1-sashal@kernel.org> References: <20210628143628.33342-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.238-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.14.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.14.238-rc1 X-KernelTest-Deadline: 2021-06-30T14:36+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fugang Duan commit cb3cefe3f3f8af27c6076ef7d1f00350f502055d upstream. Add clock rate zero check to fix coverity issue of "divide by 0". Fixes: commit 85bd1798b24a ("net: fec: fix spin_lock dead lock") Signed-off-by: Fugang Duan Signed-off-by: Joakim Zhang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/freescale/fec_ptp.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c index e63df6455fba..40c5c09f60dc 100644 --- a/drivers/net/ethernet/freescale/fec_ptp.c +++ b/drivers/net/ethernet/freescale/fec_ptp.c @@ -586,6 +586,10 @@ void fec_ptp_init(struct platform_device *pdev) fep->ptp_caps.enable = fec_ptp_enable; fep->cycle_speed = clk_get_rate(fep->clk_ptp); + if (!fep->cycle_speed) { + fep->cycle_speed = NSEC_PER_SEC; + dev_err(&fep->pdev->dev, "clk_ptp clock rate is zero\n"); + } fep->ptp_inc = NSEC_PER_SEC / fep->cycle_speed; spin_lock_init(&fep->tmreg_lock); -- 2.30.2