From patchwork Fri Jan 17 12:06:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giulio Benetti X-Patchwork-Id: 1224782 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=benettiengineering.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aruba.it header.i=@aruba.it header.a=rsa-sha256 header.s=a1 header.b=Lj2g/jVE; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47zfvD5Lc0z9sR4 for ; Fri, 17 Jan 2020 23:07:20 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 36D3981A6A; Fri, 17 Jan 2020 13:07:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=benettiengineering.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=aruba.it header.i=@aruba.it header.b="Lj2g/jVE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A310E81A69; Fri, 17 Jan 2020 13:06:54 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from smtpcmd01-g.aruba.it (smtpcmd01-g.aruba.it [62.149.158.217]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5D93E819BF for ; Fri, 17 Jan 2020 13:06:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=benettiengineering.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=giulio.benetti@benettiengineering.com Received: from ubuntu.localdomain ([146.241.70.103]) by smtpcmd01.ad.aruba.it with bizsmtp id rQ6j2100o2DhmGq01Q6lrl; Fri, 17 Jan 2020 13:06:45 +0100 From: Giulio Benetti To: Tom Rini Subject: [PATCH v2 2/3] clk: imx: pllv3: fix potential 'divide by zero' in av_get_rate() Date: Fri, 17 Jan 2020 13:06:41 +0100 Message-Id: <20200117120642.97362-3-giulio.benetti@benettiengineering.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200117120642.97362-1-giulio.benetti@benettiengineering.com> References: <20200117120642.97362-1-giulio.benetti@benettiengineering.com> MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aruba.it; s=a1; t=1579262805; bh=/sLxQHfg/aqZVb+Xz/fUJEJ+9PExMYY9DoyOuRvyuz0=; h=From:To:Subject:Date:MIME-Version; b=Lj2g/jVEehHi9K1cCZ2oKSptzmPOoz1kfX8F4OqFF1HSJ5zKpZW8HMMPr3LU3Jz43 KpBl888ZMuGDzhBUQzpDzV2jau9GueuEKMwTdccudPORd2SfMzIzKBa7aeQZyru2z4 /AOOtkgoZhJjm0EZpAIxoQHUobE4OiLEXLuFvkDnWjHI4qQWUiJXo4K3a2wLpIk0D8 wPwafDAVGhbXDxe8/c/dRSmqZzNYVCYN53jxa4qSikcKkzREXpXsYwVTK2jW5Zzu/z RUoeMtPIlGRhxBL64f5c0cDK8JxKjTMGSqcTH2oIm2RM/NpqowyZwOU7o0L+AP3SV+ vbVtNNJ+AQrYA== X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: u-boot@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean Guard 'mfd==0' to prevent 'divide by zero' issue in clk_pplv3_av_get_rate(). If it is 0, let's return with EIO since mfd should never be 0 at all. Signed-off-by: Giulio Benetti --- V1->V2 * improved a little commit log --- drivers/clk/imx/clk-pllv3.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/clk/imx/clk-pllv3.c b/drivers/clk/imx/clk-pllv3.c index a540a5b68c..72e6750615 100644 --- a/drivers/clk/imx/clk-pllv3.c +++ b/drivers/clk/imx/clk-pllv3.c @@ -163,6 +163,9 @@ static ulong clk_pllv3_av_get_rate(struct clk *clk) u32 div = readl(pll->base) & pll->div_mask; u64 temp64 = (u64)parent_rate; + if (mfd == 0) + return -EIO; + temp64 *= mfn; do_div(temp64, mfd);