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=-11.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham 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 DAEE5C433E2 for ; Mon, 31 Aug 2020 11:14:33 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A80B0214DB for ; Mon, 31 Aug 2020 11:14:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="omF5s6UA"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="GsmnUgWt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A80B0214DB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=sG68qthQ5on/nkobzde3FEDTMuhGUxTFI+5MN7MKGCg=; b=omF5s6UAKoKlPJCVaa49KFczP 64TIb4NdQ8HlECxKUYB+eDU/HsqnZe+3n6zohgqvbvZlGkWyrJHc0R61B2e3nnuPEyZ4Nnmw3s+lz c5pZhvm7G2BZ1mPE0niJ5YuIKYqAesiUAKYBgJthrnF+rvSCxb1xnxWXQp3iTXiwqJcpcaHl9exKE mcmNSU6zdds+FBezVqRrww6niiXJ3Gw1fghlY6J1uXuUpb6bTfwo4DzT586eJXaaa4RxXSoAuBlVv bFFSSSIAUs/nfI06sSaYUOLs9RB3iGMcsrRyxZUheIMcf//q+Dcr49cZjVPKlBfil0X+s2FPaR1nm OBtFAdsKA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kChkV-0005Lx-8Q; Mon, 31 Aug 2020 11:13:19 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kChkS-0005Ke-QW for linux-arm-kernel@lists.infradead.org; Mon, 31 Aug 2020 11:13:17 +0000 Received: by mail-pl1-x641.google.com with SMTP id z15so2865385plo.7 for ; Mon, 31 Aug 2020 04:13:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=KBBTUkezzasRfES9/9EFu0N3ZGXxTAErhJcD1zpfrbA=; b=GsmnUgWtwwl1EZoPQ4DCbK466aPwzSlmhmKvN0mD52viXD8KxKAI/keY70XEMr1HcO COqxrD0yB4v629b7Qrs4yGnswb+yhDBHZyOjP2HcjhM1s0t0qxcibjtzcU3IeAb2uWmW daBJSnHB1kfKB0tdb6bLczbDczyMIgM2+r0y+Nqp80/5ckQBI8oqS/07QAWm7B7g2IZz y3mojYq4Cz96l9Jl9jt4AB6KtBjCMIJ2GNgpBs3qLQKIcnMGnpleHs8J1pT8ntJ6Djo5 CTXTrCQ99P3j7IbSg9dvj0E/WftKhwbPooFRW9TUsS8hyftkN1hh9OQjjyYj2D/Nj9Uk Y33A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=KBBTUkezzasRfES9/9EFu0N3ZGXxTAErhJcD1zpfrbA=; b=FfFt4SxfRiN9YesdeVk8u6yvd0dvJG7p6weMVdu+683fZx6iIdmpkoRqgSDXfx3eS2 qQ/clL8hovtt9EHxafkML633BGW77iyMkDadNx8gKRNtWFjfiisCpB1S/j5IHIe36Flv 81Gkwx/Fwzy1bAn55GBGODGKSDWZ+09KDBwsWOVTf8pWBdJjxt/yRz9UFwM0Z4Rm8KJc TYSCZmoaNZ6ZtvA+sSlXPfXY1fJJX8mihFUlJmX/KcS2XO35Iv+BojcQ8FoMwqNIjuKD mbE9pl4c/egE/yDsuHaQSEPtnxSiN+Ga/wHVldavin78xIY74rvE8TFoom9jq8HwG0RR V7qw== X-Gm-Message-State: AOAM533is4/xSFJdUvdFy2Gm0CL0b+PIqguh5WsAWEdQ2j5xzr0qCGFS ebH99ymrG0X0vN6DRVOQcNMeUg== X-Google-Smtp-Source: ABdhPJyNSHB4RYWFClLY78FTQU/D4RuTSKf/1CKsSSYRHXVGC764/n0yGVm5touXPWXJWqZK7xqlsQ== X-Received: by 2002:a17:90a:9418:: with SMTP id r24mr915488pjo.69.1598872390858; Mon, 31 Aug 2020 04:13:10 -0700 (PDT) Received: from localhost ([122.167.135.199]) by smtp.gmail.com with ESMTPSA id r123sm4166687pfc.187.2020.08.31.04.13.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Aug 2020 04:13:10 -0700 (PDT) Date: Mon, 31 Aug 2020 16:43:08 +0530 From: Viresh Kumar To: Ionela Voinescu Subject: Re: [PATCH v4 1/5] arch_topology: validate input frequencies to arch_set_freq_scale() Message-ID: <20200831111308.h5j652dnpgys2doe@vireshk-i7> References: <20200828173303.11939-1-ionela.voinescu@arm.com> <20200828173303.11939-2-ionela.voinescu@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200828173303.11939-2-ionela.voinescu@arm.com> User-Agent: NeoMutt/20180716-391-311a52 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200831_071316_948134_98A52AC1 X-CRM114-Status: GOOD ( 20.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pm@vger.kernel.org, catalin.marinas@arm.com, rjw@rjwysocki.net, linux-kernel@vger.kernel.org, dietmar.eggemann@arm.com, sudeep.holla@arm.com, will@kernel.org, valentin.schneider@arm.com, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 28-08-20, 18:32, Ionela Voinescu wrote: > The current frequency passed to arch_set_freq_scale() could end up > being 0, signaling an error in setting a new frequency. Also, if the > maximum frequency in 0, this will result in a division by 0 error. > > Therefore, validate these input values before using them for the > setting of the frequency scale factor. > > Signed-off-by: Ionela Voinescu > Cc: Sudeep Holla > Cc: Rafael J. Wysocki > --- > drivers/base/arch_topology.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c > index 75f72d684294..5708eb724790 100644 > --- a/drivers/base/arch_topology.c > +++ b/drivers/base/arch_topology.c > @@ -33,6 +33,11 @@ void arch_set_freq_scale(struct cpumask *cpus, unsigned long cur_freq, > unsigned long scale; > int i; > > + if (unlikely(!cur_freq || !max_freq)) { > + WARN_ON_ONCE(1); > + return; > + } This can be written as: if (WARN_ON_ONCE(!cur_freq || !max_freq)) return; With that. Acked-by: Viresh Kumar > + > /* > * If the use of counters for FIE is enabled, just return as we don't > * want to update the scale factor with information from CPUFREQ. > -- > 2.17.1 -- viresh _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel