Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp415214imw; Fri, 15 Jul 2022 05:52:14 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sQEnACOomZcazkKagG8GcR/nrXG/cWEbetU5ELwcA0LWUNaoRwoUBa9TMmbCqVT8GRAxAO X-Received: by 2002:a05:6a00:2390:b0:51c:21e1:782 with SMTP id f16-20020a056a00239000b0051c21e10782mr13628358pfc.21.1657889533916; Fri, 15 Jul 2022 05:52:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657889533; cv=none; d=google.com; s=arc-20160816; b=Dcy34pCqB/NHhtovZFDFvOBKbMVMuvd3ONdKhr0/htAXXvunsL7dj0nTgI9WfNDlcR uAiaP9BG9o//Wb7HeMQpqK1WYq6jzq4uXlezi+cxQBbxXXV3AsUFC6WI6h75w3NNS+rw A7V+z1ll+k15Mf31Vn6O4fjb2PVCFmLHZ/CcRtG5p/mPYUV3Dd9niyDvBHSrbCZkReu4 mUpa219uBErv9uTKb5Pj6iUSy7L87SHpJu8oE4SEsmxmkRptLhioFE8v7dzj8C6p73bw eIvcA1PpvO5sPanGTej3A2FiaT6uXdxLkmuxv32koZDMj+TgAj8yD/8Pk8LcztF4VjgB cgtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=9PzAlK3XwGr2L3CaJM9u4+5spJ/TFu+eRcQmE0ngfMc=; b=FhNJM72lTRIGHzHOd7qN5c5VfIyx0YoMTvK7fNejP9tQINWFG4MdCFfH2s8V6SCPbv FMCZHVjg7CeAMvEtiOXznWAlBDc3u6kE87y/dEJ0Q+VBrwOilq4u/yKbZXeLflIsen8X UwDVgQn2ymPVG8f8wM31hreLHj6FOmhbV4zlpJZ9emylSceX3g6ujvLXpwi76xhuG9et 53ZXPOqUfRrHBpoAkrI+85BpNVF18LIvQj/M7W2AA5E+PiVjoHpCh0MCHSss8xgt08QF Eh730WPvSuAGohYWK1PFmo4D/YAzLMTrgePzq/PYpTUluQjnR9VIQ8V59wcVlNKc+sqI 3WeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=ri0utD3v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w24-20020a170902a71800b0016bf6ad1039si2487416plq.261.2022.07.15.05.51.34; Fri, 15 Jul 2022 05:52:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=ri0utD3v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232636AbiGOM1D (ORCPT + 99 others); Fri, 15 Jul 2022 08:27:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229725AbiGOM1B (ORCPT ); Fri, 15 Jul 2022 08:27:01 -0400 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F487820C2; Fri, 15 Jul 2022 05:27:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1657888021; x=1689424021; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=9PzAlK3XwGr2L3CaJM9u4+5spJ/TFu+eRcQmE0ngfMc=; b=ri0utD3vBK7XltfRMdNdHU93QoviRT+gD8aZjwX627ETx+7rOtxk41qE aEI3oVu+zrkPv7wWkZrv644BUb18Z+WHgW4TDSag5NUHbXObzhfqMpKAf ymHYXoz4MlGFu+kOdQWihgeT84aZAE8fv6XEf+TwCVTEZDJgdo6VaZgtw g=; Received: from ironmsg09-lv.qualcomm.com ([10.47.202.153]) by alexa-out.qualcomm.com with ESMTP; 15 Jul 2022 05:27:01 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg09-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2022 05:27:00 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Fri, 15 Jul 2022 05:26:20 -0700 Received: from hu-kshivnan-hyd.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Fri, 15 Jul 2022 05:26:17 -0700 From: Shivnandan Kumar To: , , CC: , , "Shivnandan Kumar" Subject: [PATCH v4]PM: QoS: Add check to make sure CPU freq is non-negative Date: Fri, 15 Jul 2022 17:55:39 +0530 Message-ID: <20220715122539.3978614-1-quic_kshivnan@quicinc.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org CPU frequency should never be negative. If some client driver calls freq_qos_update_request with negative value which will be very high in absolute terms, then qos driver sets max CPU freq at fmax as it considers it's absolute value but it will add plist node with negative priority. plist node has priority from INT_MIN (highest) to INT_MAX(lowest). Once priority is set as negative, another client will not be able to reduce CPU frequency. Adding check to make sure CPU freq is non-negative will fix this problem. Signed-off-by: Shivnandan Kumar --- v3->v4 -used 0 instead of FREQ_QOS_MIN_DEFAULT_VALUE v2->v3 -changed commit text v1->v2 -addressed comments from Rafael -changed commit text accordingly kernel/power/qos.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/power/qos.c b/kernel/power/qos.c index ec7e1e85923e..af51ed6d45ef 100644 --- a/kernel/power/qos.c +++ b/kernel/power/qos.c @@ -531,7 +531,7 @@ int freq_qos_add_request(struct freq_constraints *qos, { int ret; - if (IS_ERR_OR_NULL(qos) || !req) + if (IS_ERR_OR_NULL(qos) || !req || value < 0) return -EINVAL; if (WARN(freq_qos_request_active(req), @@ -563,7 +563,7 @@ EXPORT_SYMBOL_GPL(freq_qos_add_request); */ int freq_qos_update_request(struct freq_qos_request *req, s32 new_value) { - if (!req) + if (!req || new_value < 0) return -EINVAL; if (WARN(!freq_qos_request_active(req), -- 2.25.1