Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp566911imw; Thu, 14 Jul 2022 06:50:58 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u0pDQmhWv/jCzm+uHQ3bQ5RlrLwVqaqjEMWvpJ3MQ18e+WWPnZAcy2Q6Pq5++QH74wiGy5 X-Received: by 2002:a17:902:e943:b0:16b:db5b:4fe8 with SMTP id b3-20020a170902e94300b0016bdb5b4fe8mr8191832pll.38.1657806658516; Thu, 14 Jul 2022 06:50:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657806658; cv=none; d=google.com; s=arc-20160816; b=qvZUM/ecBcZIVdBXJEqjrbVLc1b9np4VMKYi40txWkrbTg7jK7OIN6OhiC9ym587VS 06hVB+wqGcAP0HUkHu3/L5OTD9BUClLsBAoIMX9jz18I+uAFNYzbyd9/3T5RBzOxz7jp WWpRpIkTv5orFB2CEcIjfbq+/FeBDlWGjpkx0kiGaC7xRItM8LtqsgVpEoUcHJZnrhvE 7290/LKqvvWXlStRyavu2pCHvGD4gJuvDzlnP516mBWi2dq4pjtbhfBPkgBU2iRfQZuZ kFj7iu49Zk0x6OVPMnmW45KzelLMzUbbdrkhP9uO6h87rq7XFoJnajW6aJDMBTH/sqQG qx+g== 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=gHdsixsz1auIu7i5568UQTbakjMkD0Fc5TX5GEXk8js=; b=THjFtrSPhgVmoFihd7C6EA3IZ3gcA8nPfeUmLCfSDEfq6KQ7uYgQoo/sPUXYI1t1FA A5HvoYl7l0BlQ3gb/6BLE/qP0FSkdY+h83xqgL2xbTK2OldWGSwOSTWNbKYtV784QAFZ NIN+1NKNl/pxDAlmPWzRcYwfxnD32LDUaaIcyqEXbO84QZj38/3eURIUXHYBQ/SNWW7X 99eNc7Ck3BesrSmXpBXKskyZHbbE2CtXIbMKz0YzXtwSYA1I6JpbkP9MMlaPIzcu7iJE L5vpSt5lIw9+acGWDkS4jhQ+EMYvuWmBtUAKNqlg8IdJUrupBW8Tz3R9hqdqgNK9VWbh V71g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=bDjfwwaM; 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 cp27-20020a056a00349b00b0052ab8ebd7b4si2250230pfb.74.2022.07.14.06.50.45; Thu, 14 Jul 2022 06:50:58 -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=bDjfwwaM; 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 S239306AbiGNNoP (ORCPT + 99 others); Thu, 14 Jul 2022 09:44:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239871AbiGNNoM (ORCPT ); Thu, 14 Jul 2022 09:44:12 -0400 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9E9452477; Thu, 14 Jul 2022 06:44:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1657806250; x=1689342250; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=gHdsixsz1auIu7i5568UQTbakjMkD0Fc5TX5GEXk8js=; b=bDjfwwaM29YNs7jUwoGItV4pdYvFwVzL+CVKXpZwGymf/PGkpQ2m1lye U3sTLOW8ZDZtYYwDQbBiNs/kf2Cx5HmwDd52mwjV1Ll2ODYofwdpOyIpY YVZz8Q+Xnzml49/o0M2QnsGs1L4GAwP92dE2LQ2jb7KpR8TKGH8H+cAhu Q=; Received: from ironmsg07-lv.qualcomm.com ([10.47.202.151]) by alexa-out.qualcomm.com with ESMTP; 14 Jul 2022 06:44:09 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg07-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2022 06:44:09 -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; Thu, 14 Jul 2022 06:44:08 -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; Thu, 14 Jul 2022 06:44:06 -0700 From: Shivnandan Kumar To: , , CC: , , "Shivnandan Kumar" Subject: [PATCH v2 1/1] PM: QoS: Add check to make sure CPU freq is non-negative Date: Thu, 14 Jul 2022 19:13:42 +0530 Message-ID: <20220714134342.3498384-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,T_SCC_BODY_TEXT_LINE 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 some value greater than INT_MAX, then it will set max CPU freq at fmax but it will add plist node with some 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 --- 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..27e6596f287a 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 < FREQ_QOS_MIN_DEFAULT_VALUE) 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 < FREQ_QOS_MIN_DEFAULT_VALUE) return -EINVAL; if (WARN(!freq_qos_request_active(req), -- 2.25.1