Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1484847yba; Thu, 25 Apr 2019 00:04:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEHxH0zJ8oW5pz8wz9UQFqplFThvhxzWsPB7vmV4QnRUjo0FGPTQzfGD6X8OOBM7jJlm/w X-Received: by 2002:a62:5582:: with SMTP id j124mr38539254pfb.53.1556175893254; Thu, 25 Apr 2019 00:04:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556175893; cv=none; d=google.com; s=arc-20160816; b=rLO/9D2jbo+ESK3oTEtIvf6wBLzDKfzUrB/nN07zT300MMbxuxIu4Yd/U5JXdw/p81 H4FtweVusMtfz/e/bkODP8vk09WlD8+nU+p7aZ4YHCBUN5i74ii6yiFSnGkotJlWf2Rp yMYeULGyO/HvkeUz9oJyV/Klueqmx0nb0izvUSoCMJ9TWPzh15O9g2wQw5B/Raxcspfq lfLBs9D1WY04/Svpc65vCHev9FgqHUzzerLx67FpvOKpOEdIjj33xpc4/NdL5EGeXrOl Ap7cxYeIdAxdWMvAaFG7OLhdrIioXxCpDMPW00iOSKwCGuuHMmgcGEV5l9M5t+QVIQyn OQew== 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:subject :from:cc:references:in-reply-to:content-transfer-encoding :mime-version:dkim-signature; bh=fKZfbSTm3ASIYlZOHXdkIBnBoQpPas2sGS5Ds99U/44=; b=fyxUsvinLRIpbfNssPT+gticu9sxrInRBZYD2qu7y0FxLRNYSBVz0OCRFCQERNo+xN mkYfdyBp7BkYA7U9rTRqilhK785kEOy/mbFn8ckFNidsGqZPMVB68Y3xH+aE4N0FJPTj nWRpJFqmDmG001e8q0M6qw6VnsKQBM5KdIJJiQjxWppcJwSs6lN7EVL6gxae7W1bzGCZ xCQnwXmOEU+XIRh3HS4spPCO3u8oY730d+iK+Lx+vvTrwAsayCmn/sw56HpOzqb/KHvv +RzPUxoLZ2ER+wde+GKfDuPfFWhxpcFne1gPOmRQWxtSdUSZwSkUaYZ95FcGv5jLLJIN xKAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P4Z1foV9; 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 n125si19717188pgn.389.2019.04.25.00.04.36; Thu, 25 Apr 2019 00:04:53 -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=P4Z1foV9; 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 S2387641AbfDXUzs (ORCPT + 99 others); Wed, 24 Apr 2019 16:55:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:58292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387467AbfDXUzq (ORCPT ); Wed, 24 Apr 2019 16:55:46 -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 E70F82183E; Wed, 24 Apr 2019 20:55:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556139346; bh=JB2pTfbdLCrFKBW53Eyyh+L38zpGBWdyy93V8mYDvr0=; h=In-Reply-To:References:Cc:From:Subject:To:Date:From; b=P4Z1foV9w7fCW+EHFfiEe4Tq6PwO+l8457MoNdkEdTofYAXQ1dlspOoXsOe4gp2M9 0gf1dnj+5VZoiRNQ2E5g8Ct9h+9w5pIRNcdoFU0NMoP9CqULZ4yqWqmElCOUfbHoy6 y5vzEHDR1OvXXvdUJ0YcChNBynhN9S0ldw+ORd2A= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: References: <1553954142-65515-1-git-send-email-nixiaoming@huawei.com> <155606042712.15276.6873845293187802041@swboyd.mtv.corp.google.com> Cc: "linux-clk@vger.kernel.org" , "linux-kernel@vger.kernel.org" From: Stephen Boyd Subject: RE: [PATCH v3 2/2] clk:mmp: clk-mix.c fix divide-by-zero To: "chao.xie@marvell.com" , "jbrunet@baylibre.com" , "mojha@codeaurora.org" , "mturquette@baylibre.com" , "sboyd@codeaurora.org" , "soren.brinkmann@xilinx.com" , Nixiaoming Message-ID: <155613934508.15276.10077721853967398026@swboyd.mtv.corp.google.com> User-Agent: alot/0.8 Date: Wed, 24 Apr 2019 13:55:45 -0700 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Nixiaoming (2019-04-24 08:34:54) > On Wed, Apr 24, 2019 at 7:00 AM Stephen Boyd wrote: > >Quoting nixiaoming (2019-03-30 06:55:42) > >> The _get_div() function has a branch with a return value of 0 > >> Add a check on the return value of _get_div() to avoid divide-by-zero > >>=20 > > > >Are you seeing this in practice? Or just trying to avoid a div-by-zero > >case that you've found from inspection?=20 > > > This potential bug is found by code inspection. > _get_div() is defined as a static function which is only refered twice=20 > in drivers/clk/mmp/clk-mix.c. In both cases the return value of _get_div() > is used as divider without any check. > If _get_div() never returns 0, then the branch returning 0 is dead code, > or the return value should be check to avoid dividing by zero error.=20 >=20 Ok. If it's found by code inspection then I'd rather wait until someone can confirm what the behavior should be when _get_div() returns 0. Is it an error case that never happens or does the hardware support 0 as a divider value meaning "bypass"? I'd like to understand that before patching up a potential div-by-zero case and not knowing what it means.