Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3943544pxj; Mon, 21 Jun 2021 09:54:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNBBXQYAH5Vcg9NZOzE+iSzT6TAmKcPb5jUtdmxJ+7eLCJ82w5qwc2BZc5hioCIwWF8VmZ X-Received: by 2002:a5d:9f07:: with SMTP id q7mr19891914iot.169.1624294452141; Mon, 21 Jun 2021 09:54:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624294452; cv=none; d=google.com; s=arc-20160816; b=Fn590wFzSN7+S+IryfilYEPIpzl3OxrftirOMKU1pUUAiYTucPWHLzH+Q5tQrqvNKW MWC4v0X9uwnmKGsGzBD6h878lGjlv4jg0mHHXwWXeYegO2MnPo1ly4JFKeMrG+/B/qXS GGyDjuYSS3a/bEev7e+XdyJfDnE0DI1sNETEkgwH3U7DczS+MBPx+RkQmXwZF9IrXhbQ L/k7MA6opv94s0l+lemQENu5i0jVXrvmBGeBpVaLjwtyyI6NS4tvTfyezkcNhd+fw1Yz CVaoyAck3asZ4SewAslQyQu/UAMzZ+bos5XhC9t2rRPrQ2/9XTMzETUv5n8Y4sGDFK1u C9GQ== 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=qPrxdwORIoDriFyJzTRy22yJvCLzieC74/C+glWnuP0AjyQSmQuAgIpnbJ4pI5Ffiu /IkORYQy1VxO4U1nYYh6XEX1nzd/DKiqRravUsEFl+1aYiNXArWamX8wsTDRSby2yZhY iSxV+xOsbxJN0Dm9XTGQsartSaRcAIAOqpFhf7XH4mUVjQxCnndDSSNVv8tuGtpVIxDA lCH44+4L4UUsE6HwXTNLi18J4vPuHI1q/TzbVpGgTRy2mQAcZ36PZR475UMVfu0PH12B 6tE3s9Cy/VroGx3idcBeYgOX1MDptDLtrjP2n8x5JGdtI4rAuqT+TbAcGwvjN3zFwyMx x3Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HgJg7ykt; 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 m15si13446017ilh.26.2021.06.21.09.54.00; Mon, 21 Jun 2021 09:54:12 -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=HgJg7ykt; 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 S231611AbhFUQzn (ORCPT + 99 others); Mon, 21 Jun 2021 12:55:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:41326 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232743AbhFUQvo (ORCPT ); Mon, 21 Jun 2021 12:51:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AD3D8613BD; Mon, 21 Jun 2021 16:35:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624293331; bh=pOK3xHA662ryxHR+7+aKJHhwoXev2TjUyDD95qmXTL0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HgJg7yktQ81DCBpfRe8KkdAUL0SAaMCN+WLaZk9NN/SCWUWddCnpgVuThiv1tdGze TqDDQbPotmEDbVzNVFcgiRO2ywJWGEZa+Ie8Y4JNxXMShGJfcoFvSbUpeGP3OwHE2X 8SmqOzPiMXXk5yJvSaPR6fs4jl0I+vS60BtKk6xw= 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.12 174/178] net: fec_ptp: add clock rate zero check Date: Mon, 21 Jun 2021 18:16:28 +0200 Message-Id: <20210621154928.669059905@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154921.212599475@linuxfoundation.org> References: <20210621154921.212599475@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);