Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp1320498ybb; Fri, 29 Mar 2019 02:03:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqydxEtUX1f/erBtJDwiWxrufGdbTdmr6ZOQy+eqdpZon/as+l834xtuzZo7W4yrzEbvrR6A X-Received: by 2002:a17:902:44a4:: with SMTP id l33mr47825747pld.292.1553850219421; Fri, 29 Mar 2019 02:03:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553850219; cv=none; d=google.com; s=arc-20160816; b=Z/xPP3Lp3b90OqfnjYSHDkbogBqE2MVyWsXslDWIkwLUbSekyAP4jIhpKDZrostu5c RxItqH9vAxOvNK22WvR7NuLYI6jmaonaQM0EbqSSP86h4Fq3IxHgZlwAZVgbch3R8Nye zD//AmH10atZk2GfuNLpHap9rUEbC1934KpJ4NCkrV3nRo6dg87NFitjfMXlse+tPaj2 w3lmsfYLgMJxg1l5/jMVl+uxuYwF5f3VM1hpTi3GcX8cVmu6eX56BdZBGSGIukbl0LLY G5be6eXjDATecT6Q2TtOw7vZHaRImHOS7f9woJ+Z5u0MojzRIfQMwKIq1oyuYIdjuYXk qT2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=PDhoZ8EMMgIX2nB72Fc+wKv1hmHEjvB0Rbq/hj9FXt8=; b=CKpx1j0x42rb/cUt+Xs0n03rk9OMduuTVbEN+KOI2UEoPwlsyXa6yqBWKgAP9DS5Z3 q/xLC/xJzb0NAudt1DRrQ8aZB8ZYdaS7Vn4mwRN6Ec5ST4Vd9rJbHSaozIZ77VwVp9Jp UKouTmLlh8YvAJCC9SL4TshL+/rfLELqq7lt0U72odoaGxlfoql3EL9q2Xox8zHFCyHZ VVFUkOAB1UufXMQOgaw5ENxFtpEYOYgZVKFfZDyFPDEFme5RNbZ2APjSXBQ26Q1bAsnb b+SkIuPxy5QQHzYAjrUkJbW8Hx0FcgivrMcaWz8XEm6i1tcVocxjIO132HsS7FVZBkbD c5Eg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x5si1377641pln.220.2019.03.29.02.03.21; Fri, 29 Mar 2019 02:03:39 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729239AbfC2JCp (ORCPT + 99 others); Fri, 29 Mar 2019 05:02:45 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:38704 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726652AbfC2JCo (ORCPT ); Fri, 29 Mar 2019 05:02:44 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 610B6EAD8CBD5CF508DB; Fri, 29 Mar 2019 17:02:42 +0800 (CST) Received: from use12-sp2.huawei.com (10.67.189.174) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.408.0; Fri, 29 Mar 2019 17:02:32 +0800 From: nixiaoming To: , , , , , , CC: , Subject: [PATCH] clk:Fix divide by 0 error in divider_ro_round_rate_parent Date: Fri, 29 Mar 2019 17:05:24 +0800 Message-ID: <1553850324-25625-1-git-send-email-nixiaoming@huawei.com> X-Mailer: git-send-email 1.8.5.6 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.189.174] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the function divider_recalc_rate The judgment of the return value of _get_div indicates that the return value of _get_div may be 0. In order to avoid the divide-by-zero error, add check the return value of _get_div in the divider_ro_round_rate_parent Signed-off-by: nixiaoming --- drivers/clk/clk-divider.c | 2 ++ 1 file changed, 2 insertions(+) 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; div = _get_div(table, val, flags, width); + if (!div) /* avoid divide-by-zero */ + return -EINVAL; /* Even a read-only clock can propagate a rate change */ if (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) { -- 1.8.5.6