Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3839361pxv; Mon, 28 Jun 2021 14:20:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAE0HORLFovTVzBKVEBjPV9/MPmszF5RskaMRp9fyq8X4DHgMSecaEo6/XeFbSLiZtbUDw X-Received: by 2002:a92:d58b:: with SMTP id a11mr683010iln.305.1624915248487; Mon, 28 Jun 2021 14:20:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624915248; cv=none; d=google.com; s=arc-20160816; b=nVp+16dbJy2MSLpZF22j/3tyKX8B9zfeUiPj9otTm3Lca6zfcnRNBbnY0HksGmHMle wLWoU+QSNpjqvKqtED/GYAeDKHXQdgSoT1X+53FqPu5iIsPGGTGXUvi0VVeCkxGQiWWI 84G3r1aG2W9HM+IviLNor8qyEBvd/4mRqgoZsT3Kr9+yPq4kEck6Gw3NYiY3ZWLXGm1e CwkeIO7Wm3Xdi8PegppVBEAlVdZktVoFNvneykyiNWX83QFSwlwp1VbDwsEAY8RnfVHg /vbADxPMlXnR0ORBdFJ/mifQaoicGK9aFvrfQLBjUXbHy4lwDZuaZDINugzdQ+GrwQ2a sNqw== 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=03hWe+UB5nByPL1tqxe0q7nnLKlHmwajFCHFlfQORGg=; b=lRabfAXQXN4qGQByDrQjTCd3Fr61x/ZbF1PimMAcAf7IGTd4O9YKtrxPPA4wYaJQMv EUNh2mau3+Je6PlSoXUC+EKXUPXBUY7GeWs0UeLanad+8rBZ0nUSropVLObchooBprhx FMb3a5jxw/vnrAkuusFI2riYlVdvYh9LUQkzesVA2IaptXllvfxf0sfZkbDQfwe2WjnM tnmfQAQzABf/VO1RYQm0GLKUvDl4av4gScP0It2qBwFDSyOFiISbXIHxMlRaACG1cYmj Fv2HmV0oeuxaGgfPO3BpkuvlBBKi41AK65nf2ysrHwbRVGKEbcabPiPHQn6TcrJdZF/P O/ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Sdiw5svc; 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 d6si18089249ilm.75.2021.06.28.14.20.32; Mon, 28 Jun 2021 14:20:48 -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=Sdiw5svc; 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 S238107AbhF1PY1 (ORCPT + 99 others); Mon, 28 Jun 2021 11:24:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:37040 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235956AbhF1O77 (ORCPT ); Mon, 28 Jun 2021 10:59:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E0F2161D60; Mon, 28 Jun 2021 14:40:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624891243; bh=0GmvVOHkxS3zDugced8sL6PhjzPR+8l3H4fe45G+F+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sdiw5svcmU2sWjsx8wLIJRaM0W/owR2Qi0nUe7pgH9AAES2fcIgv6XsoRRtae2hId rmIRHsOieOaTm/plbKwsLe6VKJlNV0RRgx6b5rVbgBDQUia2iY1Tya6FViDYae5yLm 1OKNPhV96oVCVCNCKUNQUxg4fpQhks0SnEfPi7KqqFu6OOW8jOw7nliOBfzn3Y249O NMHWLaNaoXN57diozQTTCVdx1UzbaBHX+kfXT6UCll74M9MO+S1tKWT3OUl3RzVaAY v/EATfaTAVL4hpLD0k5WGIq9jcBlSqj+vpHfJjj1MnqYcMEirEwhHmgn1cnYi0ofWO lghxnmxRAHr7w== 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.9 44/71] net: fec_ptp: add clock rate zero check Date: Mon, 28 Jun 2021 10:39:36 -0400 Message-Id: <20210628144003.34260-45-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210628144003.34260-1-sashal@kernel.org> References: <20210628144003.34260-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.274-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.9.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.9.274-rc1 X-KernelTest-Deadline: 2021-06-30T14:39+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 123181612595..031d4b3a544c 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