Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3930774pxj; Mon, 21 Jun 2021 09:36:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzPBVpkTbLoyMYq9RXNJI40Yre8Pl5zd5Iq6A0t568uX42//dJGGWyXoN3rhXoHeXGjBJ9 X-Received: by 2002:a02:44c6:: with SMTP id o189mr250362jaa.90.1624293411772; Mon, 21 Jun 2021 09:36:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624293411; cv=none; d=google.com; s=arc-20160816; b=jIeP3wZsTJHaLTxUBpEMAX2Ta11k6e8IFRCv4oRmEyQ0EuDSOBUDKcUsp7V9N6lLvo l5N3oeSOePghqQETuUUiGVo3eMRwdkkOVAnCwJ69KGctvKH7WvTPNwhOng7vKYQdOBib SLcQ9q+Tkl2LAGeYyHj18NJaXwNJwQ3bo2dDlGguGuv5mL6xAoi3+lfA+7Oo22FVuuL6 z+j0SM8x8yVsg1fOIhIcKswInn8IK1TCr3NYA1tAKzlIWAaM1VJtep/cF24piWaGax4x jEoMzMoYtAgPaRsTZ/bPIHGZAY0pwGcjGnTjNf91BKfgaCvm/gBb3vDWwtdLIXlRGl9M rkwA== 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=47XWoQ2CnbnCsLgbYa7fruD9IZlA7ZHTIvvPV4jgO5s=; b=zmNC7hUZHCHmnfa0H275KZvY+h5douMRdbf68i8671f7BbM0tNFN+K6tUFxYmoK9H+ 6W4IMEdI3RNOr+W+PtHJOFC9oPojM6rtfpJY0Z0C1pCMzVLGJ2Hgp631uleNuoPLn7Lc 7GoALjVSN4HUnHmbh/Zrjh6L0mX3imX/tCace6YCBwSU6HTVRYzEm/9ET6nHAjHq/fNF UT8tWPIniodHMIpzLSzT1qO/d0IAG/LwoHPZzb97JeqD3pnf4VfVq5g0xXdAsQZkj6OF NfRQQ/PAiKwKjk9kNU5eDDGYeyTJjLiti2DTdKJbE8dCz5UVhvx2bqNG0QZuoJ8W8t5L AVWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="1G/WH0rv"; 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 o12si9696087jam.119.2021.06.21.09.36.39; Mon, 21 Jun 2021 09:36:51 -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="1G/WH0rv"; 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 S232942AbhFUQiX (ORCPT + 99 others); Mon, 21 Jun 2021 12:38:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:55922 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232845AbhFUQek (ORCPT ); Mon, 21 Jun 2021 12:34:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C5899613B4; Mon, 21 Jun 2021 16:26:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624292819; bh=pOK3xHA662ryxHR+7+aKJHhwoXev2TjUyDD95qmXTL0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1G/WH0rvljPp7x8mS6cv5UPNfia2ZOLc4lUgdbHKAMUeCTM1M4bE+j6YUxo+PrxFP kTpk12CWtjYARHi1uXlVUSRWAIlKMP9DbHrOablwN1FQIz+7EMlKCTlnphLuyElwQT moS6Wz5rS2Vp4Kcwm5+yVO57wgaF3ixhMgA7quQU= 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.10 142/146] net: fec_ptp: add clock rate zero check Date: Mon, 21 Jun 2021 18:16:12 +0200 Message-Id: <20210621154920.609697570@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154911.244649123@linuxfoundation.org> References: <20210621154911.244649123@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 @@ -602,6 +602,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);