Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3922063pxj; Mon, 21 Jun 2021 09:25:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzv8SgVnN0Ik/bbxNCUNLX9lSy2OtyY/dhDWJ/yvAhqstkYnnJ6t2HBmLtGzoaQx3xcK72o X-Received: by 2002:aa7:c782:: with SMTP id n2mr22776089eds.77.1624292754009; Mon, 21 Jun 2021 09:25:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624292754; cv=none; d=google.com; s=arc-20160816; b=fyCLyd0fctW0PHH+/NnMc2HC2NhEgqcukk+Ma21IiXLHSDZzF03/knsvgLbwsFDlnX feMMM7cyEwCU96vL32rxYybinRFi64c1m5JoO2Gip3RWvnLXte7RhASkhF8q8qI37kqT 2ptIyWpJPwDsZASoIVDfo5otgE4s8rGb4fopW5DhewNCuNGMWatGb/gGds1ZSneXD9JC Eewa+vzAR7zKYYmd8CggpdYs6x3KaQCrRFa+iDfUBParG5NSQajjHs0toSXRNQgd5yFT /RwyGmHNrTYjKHGmbja8CZMcFwvTP5lqgAqoXdspnj2dL0B3VnFDFlhcel6Qg8o+xzVP crZQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fsx/z4ClgQI62b8WXHp7DruBKzYwXzQp1Yj3Jtwk7mY=; b=ScsVHAdJI7GXqzfU9xpcjioiWobA2YKBCKiV2ud6tj9F3RLgO+5I2BLR1mnklu9Aiz wy9c/vbnd82dscakyG9SL8KuYf9yyTNYPWSu2eI26DI+/ufDIhSesO5nzpmHJtVGRPcS Zb3geolNYL1eZYFUnwK1dc5Px8ftqgy3TA0w6TqQA33L8ScyzGnJ43LOYHJAIepRCzDu t1ERGDSRvl4b942PITtGziTWicChsR40hw1ATjtqlZbkeL7HC+D+o7WqIbgVd2vozkj+ run2XzxaihZoKs2r2E4D5gHSvZNhwBlo8BdyHknFgsDGCw7WkJ87ZVK4iXgwO9+mOR9h Tx+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tFn2ibuK; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m5si11194966ejn.23.2021.06.21.09.25.31; Mon, 21 Jun 2021 09:25:54 -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=@linuxfoundation.org header.s=korg header.b=tFn2ibuK; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231201AbhFUQYR (ORCPT + 99 others); Mon, 21 Jun 2021 12:24:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:42682 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231631AbhFUQWj (ORCPT ); Mon, 21 Jun 2021 12:22:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 449A5613D9; Mon, 21 Jun 2021 16:20:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624292412; bh=SlvRAC2UFVhxKZ31Bdbk4MkxU9I7shKIIRhkb3Z1AtI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tFn2ibuK6TPhBNVyOSyTfwY3+58lCvRdCDGACMB+TV6LLkwyy6iakyvzVRRDVx7gv 2eAkJFDFPdopEEFf6Nzg1Ku1/vfmaCNByG9u59WHT0/0aBqCpl9DkpM3Ejcsu8LzIW OKqaTM9fzFt8tZ0gtY7mKLibGmmx1dz+ToDIc908= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fugang Duan , Joakim Zhang , "David S. Miller" Subject: [PATCH 5.4 82/90] net: fec_ptp: add clock rate zero check Date: Mon, 21 Jun 2021 18:15:57 +0200 Message-Id: <20210621154906.922654357@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154904.159672728@linuxfoundation.org> References: <20210621154904.159672728@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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(+) --- a/drivers/net/ethernet/freescale/fec_ptp.c +++ b/drivers/net/ethernet/freescale/fec_ptp.c @@ -597,6 +597,10 @@ void fec_ptp_init(struct platform_device 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);