Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp395809ybh; Wed, 15 Jul 2020 05:02:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHs+JQiMGo+ATYQQ+tQpnU8c9A6J+xn9856gfMgpGnxuxpxaspDdDaplHn4F+9ZSxkXEAa X-Received: by 2002:a17:906:40d7:: with SMTP id a23mr8622555ejk.421.1594814577866; Wed, 15 Jul 2020 05:02:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594814577; cv=none; d=google.com; s=arc-20160816; b=nbsJpTQPoBje+RKbaUiToG5p8COVv36RDQX09DMW2iCx0OxU6W18LThGoMKAac+C4h 4E/+8lk7wMYqZruC+wuTAnkAO1LGTtePOhLUyPIyxVTDsk5NNcWBNm8uhz5POwzVbNlr c1tXbYbhJVwBEOrPR38DRrNN0iK0eBMb1TWoQ50n2/qszsXzWN6Innb9b87RYDZhLIsI bQ3f1E9CyNd/iMKeCRZrEL+PMUH3w6I5mGQ3XbHTYAgdyq3pcDWgh50y4esVT6jZgdmI GXxNt7G+hJVJnQE3j5SxPlkH8Zy3gX2DfkopA/MwmuKdPGL9HP9Dni1cnDb8QT84i4ec haCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:ironport-sdr:dkim-signature; bh=eGKC/hMedIJ3Mj7QGUN8aUWXeRQwiKzGDJuv4pYbSF0=; b=CBb3+NYeVjFkaeZi6yM1rrcps1ATP+iIsnlpU7TPbOCCha7+xQ2qSx2MFRDvv1oNbx Hc+8W8gJonWAY8DAqafd3Uc3VYtUaW+iT/NraT+TUaNJFTojTYZ9tg2WW9BzMmi4O3iI 4SU7FSUzqgZN8duFFG3P6f7EAQSi9oxtiE2jPxHoP1pvsTZSeOINB1bJ5PUQc/ttUn2l PO4TBv0PXI3xCdkCajmw8UPFdEHG4M+GLf94iiKAqYj5OWwtlkGv2BgfO//9PhuuI2Gu mEOQR1O5DSa6UwOtwcCL/kxRhkttlRxhBlRdkS3Y2ZsQmeqhAZlgJHg3LO0jpIR7927F jWig== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@microchip.com header.s=mchp header.b=DCXKH6nq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cx20si1017242edb.568.2020.07.15.05.02.31; Wed, 15 Jul 2020 05:02:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@microchip.com header.s=mchp header.b=DCXKH6nq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729853AbgGOLYo (ORCPT + 99 others); Wed, 15 Jul 2020 07:24:44 -0400 Received: from esa3.microchip.iphmx.com ([68.232.153.233]:62426 "EHLO esa3.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728010AbgGOLYm (ORCPT ); Wed, 15 Jul 2020 07:24:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1594812281; x=1626348281; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=SnrVXchj5oje7KzV5m8bHCbpwoS/HOfvs9d3eno49eU=; b=DCXKH6nqp8d59zRluP4VK+M324Z6k4i0nYgPksxtnatYE33IeYTpO9JC MEZOxnXaE6TKCFbHQmizzW5FzoZArcW7xAzUarydrEYW3ozE5ap9m0Fhl 9n62R4QQ8G/gYYiVxM7/CK6NnDspq5GwNirC8NZvGTAxSVcJMQdhcQpQV jYPBG8Z+upNEZPU1Wzsy8FoWN6osLe15GiYAeHo/oA//Vs+54fwkmUPVO HrNim2zRtDELGHWdkU4y6eFMGZxNApGaxy9rMAxACdBtCPVwLl8qVwEFP 4O1PCWYY5HFS6TAZrCrD/eTpESKZxy0LY1D81no6Gn4FfQBLnmjac39dm w==; IronPort-SDR: PXXQ6iws6jNB7HWOdIevOcnYrYk/9g2UBkrGV+A9h60NqbExZ4FrpSUp/u/MIb1DMX0e1IO8Ta 9f5pXkGfa5cf/DVwWI/tDGgsbHWOPvvA4F/hRHZwK+wrgRIAMhjFYbePyKbyB5I/ZgDs7zJjAs xGOLgQ78ySdQ5c5Jr02MuInBAwFoRyMenENGoHA2F50wZO/RNgwtPbCzjPzXhJeJMwWumFp9C1 EAOYR62I4rmsIA/F6ThJUOHSkNmwtwOIbcOwC3w9RdLdfVZ45BpBZ5CtUNCI1h63wcrMYgSiF9 06Q= X-IronPort-AV: E=Sophos;i="5.75,355,1589266800"; d="scan'208";a="83962772" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Jul 2020 04:24:41 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 15 Jul 2020 04:24:41 -0700 Received: from m18063-ThinkPad-T460p.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Wed, 15 Jul 2020 04:24:06 -0700 From: Claudiu Beznea To: , , , , CC: , , , , "Claudiu Beznea" Subject: [PATCH 02/19] clk: at91: clk-generated: check best_rate against ranges Date: Wed, 15 Jul 2020 14:24:10 +0300 Message-ID: <1594812267-6697-3-git-send-email-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594812267-6697-1-git-send-email-claudiu.beznea@microchip.com> References: <1594812267-6697-1-git-send-email-claudiu.beznea@microchip.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Check best_rate against available clock ranges. Fixes: df70aeef6083 ("clk: at91: add generated clock driver") Signed-off-by: Claudiu Beznea --- drivers/clk/at91/clk-generated.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/clk/at91/clk-generated.c b/drivers/clk/at91/clk-generated.c index 995a13133cfb..f8e557e0e1b8 100644 --- a/drivers/clk/at91/clk-generated.c +++ b/drivers/clk/at91/clk-generated.c @@ -185,8 +185,8 @@ static int clk_generated_determine_rate(struct clk_hw *hw, __clk_get_name((req->best_parent_hw)->clk), req->best_parent_rate); - if (best_rate < 0) - return best_rate; + if (best_rate < 0 || (gck->range.max && best_rate > gck->range.max)) + return -EINVAL; req->rate = best_rate; return 0; -- 2.7.4