Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp1980166ybb; Fri, 29 Mar 2019 15:42:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqx4OoBv9jXQb0VBa+yOqvcGzthVHBm+7NW5IK8k3NPZTaAzu3m6Njtb/OTytznGwFmmt0qG X-Received: by 2002:a62:4595:: with SMTP id n21mr4563831pfi.79.1553899376204; Fri, 29 Mar 2019 15:42:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553899376; cv=none; d=google.com; s=arc-20160816; b=ewFWW1QnTnKVF/V87/kqEXrSsYmGXcFvovmSGTslquwbdXko13kYMx5t6nnFekEhn+ 7vPao2x3bxxC0L7q2tqnPoi475cpUZkjqbWXb1HetcgiURqPUBUMpOKT8zrzQIzgQCcl SJG/AYzU543KOduo0DmL0z/tcU6Of5LYdGVwFFIxmEfhUFGZo8DG+fQueFpRzozmX8pB Zcr9VYbLEkEoA5iphzNDCwrId+2lUWZ1SIGIAMrR7Lf6PCha0VWLMt4TVjyUvNQNHDLM vUFkyzkH2hskCuYP2hCKjWHQBv3LkI5NTuCpHnioDtnGK5LrKpiuEuv1Md1rMyyq39ls AzLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:user-agent:message-id:to:cc:subject :from:references:in-reply-to:content-transfer-encoding:mime-version :dkim-signature; bh=J0boJNkXPa55kW4Br85kPoipuvqemu2Na/r2WAfgQWo=; b=USt4MalAwMpInmt/0miyt2+iSSHCJXCiHurcbyda+14vWe08A1Vgqj/q605cdhZDgI gc1vLdzv0ydzpk8QgDI86MlX2WHfIIHycPpDqqzzOOk3ftrNa/W8cH5xIs0rzIznw17F 2QvdUOiohvEtjy4mu2g04pTXSSSCQmnFlUKRRTwZ2Qr3iYv018Xn7sFz4U2x2S3h4hcj o4m3PTOPTarnWXJ2NVNB9gPU9tkCJPVIyu5O+iAlLsYLezMbBHOqGP1tg29VXRAAgjj4 17Ub4b+z5DhcczQWDRBAiZ5lmkwWf02bnd4Lv/iHC5GnBYYdmS7XS+DFrGtCmQCnCD1u 2d6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hGatEvv+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id j37si2937336plb.236.2019.03.29.15.42.40; Fri, 29 Mar 2019 15:42:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hGatEvv+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1730514AbfC2WmF (ORCPT + 99 others); Fri, 29 Mar 2019 18:42:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:52554 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730062AbfC2WmE (ORCPT ); Fri, 29 Mar 2019 18:42:04 -0400 Received: from localhost (unknown [104.132.0.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 96AA1217F5; Fri, 29 Mar 2019 22:42:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553899323; bh=NyAqODDr/8UfYBpcXxCTkCgR2venfW3HzkWlCOuQxh8=; h=In-Reply-To:References:From:Subject:Cc:To:Date:From; b=hGatEvv+AEX0SbUVXTpRr6ED1e2Lc2hk/mEq8PAvRWj1GXC/HxhUPGp+zUaJanHKf lpy3UI2EUajljwffnm5h0GzQZOMj/s8GHe4plPKE/VE2p0LaTI9LGNMJTtdD+wZD/b aZqg8E06i2ECZSlV0IjvO98kPaY97ioaXzNm2tcA= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <1553850324-25625-1-git-send-email-nixiaoming@huawei.com> References: <1553850324-25625-1-git-send-email-nixiaoming@huawei.com> From: Stephen Boyd Subject: Re: [PATCH] clk:Fix divide by 0 error in divider_ro_round_rate_parent Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org To: jbrunet@baylibre.com, mturquette@baylibre.com, nixiaoming@huawei.com, rnayak@ti.com, sboyd@codeaurora.org, soren.brinkmann@xilinx.com Message-ID: <155389932276.20095.12054188967513679921@swboyd.mtv.corp.google.com> User-Agent: alot/0.8 Date: Fri, 29 Mar 2019 15:42:02 -0700 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting nixiaoming (2019-03-29 02:05:24) > In the function divider_recalc_rate The judgment of the return value of Please write divider_recalc_rate() with parenthesis to show it's a function. > _get_div indicates that the return value of _get_div may be 0. __get_div() > In order to avoid the divide-by-zero error, add check the return value > of _get_div in the divider_ro_round_rate_parent >=20 > Signed-off-by: nixiaoming Is this your name? nixiaoming? Or is it written some other way? > --- > drivers/clk/clk-divider.c | 2 ++ > 1 file changed, 2 insertions(+) >=20 > diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c > index e5a1726..0854e3e 100644 > --- a/drivers/clk/clk-divider.c > +++ b/drivers/clk/clk-divider.c > @@ -347,6 +347,8 @@ long divider_ro_round_rate_parent(struct clk_hw *hw, = struct clk_hw *parent, > int div; > =20 > div =3D _get_div(table, val, flags, width); > + if (!div) /* avoid divide-by-zero */ > + return -EINVAL; How does _get_div() return 0? What is the value of 'flags' here when this goes wrong? > =20 > /* Even a read-only clock can propagate a rate change */ > if (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) { > --=20 > 1.8.5.6 >=20 Wow that's a 5 year old version of git!