Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3893787pxv; Mon, 28 Jun 2021 15:57:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6smbrkt+0nyb7RdF9/FHUPZhJCowBoMzvy20YpJhbEy+c9lZFjDanjRkwZIcbbZ787/o0 X-Received: by 2002:a92:c7c5:: with SMTP id g5mr20392882ilk.153.1624921058164; Mon, 28 Jun 2021 15:57:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624921058; cv=none; d=google.com; s=arc-20160816; b=sdJe5JBe1dsaBVW940I2zv3+D+pr+36c2MOn8qCuA4n/ekLdECb5m/YAJ3I3R25B+C nv2NXBUqdnRkB0sXBTdnrtiREwG8y5i1ExEyEzBndyu6/NY28ie/aSMB36eUBNppulzd 3w+Es4JYHP+VnGXRKRYi94OzfvfQVNQmsX7ppDfg5QQ1jVCiXVru/ym2rFaQSocZ8PB7 fvueVXJ/BhBIJ/lesaERs9HX5fXAYUyobKFf6GfeqziLsmimIDg+EwdhbbYVybUEcTga 7HgpEVzbNTuHaCbyOj01RJL4oD465vrUw05snbnn4fAZKCCQmqrBEOgn5R+i45dtbegS EKSQ== 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=TvrgpLdPtpF5h75s1H4cy63ofSUKsm+guMP1Cuj7XveLxm4/jVFZlFrrpoM7qtP5Ut MPNaZz4IlQTsYRAqWsDayrsXmjaQhCrrnRy0CypW7txeAJ39GUOOe9gVQfQ5rL+dgm2l ZeWFYzMkNmzcRmITAdYRKK2uuoJOOoRWzaoW1cRuoub62R/ovvLQTbOoCxo7fX++yI5B 8EvvXW+gkHzaHENPpTk6bCXnwcr49FARtMSnmHTznvpftPoawashBSrSanpu2GaKmLn7 oIWysXZxNS6qFjWDrT/E7qEmyAkUPkW3ntzOx378ZJ56108pgBlv4q4NDF5Su/bjs9TN 39Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iB8HrBkn; 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 t21si13676262jai.3.2021.06.28.15.57.24; Mon, 28 Jun 2021 15:57:38 -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=iB8HrBkn; 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 S238828AbhF1Pa0 (ORCPT + 99 others); Mon, 28 Jun 2021 11:30:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:39674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237241AbhF1PF1 (ORCPT ); Mon, 28 Jun 2021 11:05:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3094461CFD; Mon, 28 Jun 2021 14:43:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624891409; bh=0GmvVOHkxS3zDugced8sL6PhjzPR+8l3H4fe45G+F+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iB8HrBkn3JD8bNZ6IPP/cF3KA0sRfKoUvPEWaT7D2GYrYD67TC6mVNzffIs5gHxe4 p9nocKG62qaKz8wXmRR6PW+u09gcTwm0dcAp4iYF/j0yF/T03W7CXLNvG1KVZPJ4T+ Zcugli/zw65BQAZ38CIn9eM1dObx4yHgWqBopjDNS784ZCe6wqCH0ozc7cVxev4LAY 1S3Z6nOSbifW1HEuzAY2zSJfm4enqSSW6l+rBdB7BE2b/hlwIdCf/+xdPkVt1CwH6R nLojr7o/lbToXPskWfhFrev73JIk6VN9ELcTZu6VUiU05ysATb1JZPIcA6TY+SwlI6 worCSesiQ5ekw== 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.4 37/57] net: fec_ptp: add clock rate zero check Date: Mon, 28 Jun 2021 10:42:36 -0400 Message-Id: <20210628144256.34524-38-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210628144256.34524-1-sashal@kernel.org> References: <20210628144256.34524-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.4.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.4.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.4.274-rc1 X-KernelTest-Deadline: 2021-06-30T14:42+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