From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F89FC3A5A1 for ; Thu, 22 Aug 2019 17:34:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 481652064A for ; Thu, 22 Aug 2019 17:34:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566495244; bh=PlMqAN8+epMELBmyC4iK2dJFZedqwDoHhpGBl5HPV+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=liBR/3TTpbJkMpXs4QZQIe3eAUcILbuJkO61SujIvJi48bIE1/sgbHrc0jBE3eKJe MfkCrLsFsbOAjczGQHU5iBfoUc58PXE/SrCpilJxPKD8FldwulbbhivLDGcYjBKsee 5SpMfTjxeEaMy2C2m3bKtacGobBqnoYJg9Ah4h/c= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392605AbfHVReD (ORCPT ); Thu, 22 Aug 2019 13:34:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:49442 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404447AbfHVRZf (ORCPT ); Thu, 22 Aug 2019 13:25:35 -0400 Received: from localhost (wsip-184-188-36-2.sd.sd.cox.net [184.188.36.2]) (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 835D623405; Thu, 22 Aug 2019 17:25:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566494734; bh=PlMqAN8+epMELBmyC4iK2dJFZedqwDoHhpGBl5HPV+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sAN5A1Y1ro5MSMCsJ72SQL/QopuLRFbqqtuk4lamyyAAZGY3BSYjIPTqMggz1RIOA 1dPD0HICI8ja5WsgkPtyDq+KllQJYircaC5rwagwe5mnqQb2C/0ulr/naUCfMRilX/ 9AXovNWjw5X8MEJWNJpaWo8G+kYt/sVZdGwLhglk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Codrin Ciubotariu , Nicolas Ferre , Ludovic Desroches , Stephen Boyd , Sasha Levin Subject: [PATCH 4.19 26/85] clk: at91: generated: Truncate divisor to GENERATED_MAX_DIV + 1 Date: Thu, 22 Aug 2019 10:18:59 -0700 Message-Id: <20190822171732.289391871@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190822171731.012687054@linuxfoundation.org> References: <20190822171731.012687054@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 1573eebeaa8055777eb753f9b4d1cbe653380c38 ] In clk_generated_determine_rate(), if the divisor is greater than GENERATED_MAX_DIV + 1, then the wrong best_rate will be returned. If clk_generated_set_rate() will be called later with this wrong rate, it will return -EINVAL, so the generated clock won't change its value. Do no let the divisor be greater than GENERATED_MAX_DIV + 1. Fixes: 8c7aa6328947 ("clk: at91: clk-generated: remove useless divisor loop") Signed-off-by: Codrin Ciubotariu Acked-by: Nicolas Ferre Acked-by: Ludovic Desroches Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/at91/clk-generated.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/clk/at91/clk-generated.c b/drivers/clk/at91/clk-generated.c index 33481368740e7..113152425a95d 100644 --- a/drivers/clk/at91/clk-generated.c +++ b/drivers/clk/at91/clk-generated.c @@ -153,6 +153,8 @@ static int clk_generated_determine_rate(struct clk_hw *hw, continue; div = DIV_ROUND_CLOSEST(parent_rate, req->rate); + if (div > GENERATED_MAX_DIV + 1) + div = GENERATED_MAX_DIV + 1; clk_generated_best_diff(req, parent, parent_rate, div, &best_diff, &best_rate); -- 2.20.1