Skip to content

Commit 8d36694

Browse files
Shivnandan Kumarrafaeljw
authored andcommitted
PM: QoS: Add check to make sure CPU freq is non-negative
CPU frequency should never be negative. If some client driver calls freq_qos_update_request with a negative value which will be very high in absolute terms, then frequency QoS 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 <[email protected]> [ rjw: Changelog edits ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent e0dccc3 commit 8d36694

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/power/qos.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ int freq_qos_add_request(struct freq_constraints *qos,
531531
{
532532
int ret;
533533

534-
if (IS_ERR_OR_NULL(qos) || !req)
534+
if (IS_ERR_OR_NULL(qos) || !req || value < 0)
535535
return -EINVAL;
536536

537537
if (WARN(freq_qos_request_active(req),
@@ -563,7 +563,7 @@ EXPORT_SYMBOL_GPL(freq_qos_add_request);
563563
*/
564564
int freq_qos_update_request(struct freq_qos_request *req, s32 new_value)
565565
{
566-
if (!req)
566+
if (!req || new_value < 0)
567567
return -EINVAL;
568568

569569
if (WARN(!freq_qos_request_active(req),

0 commit comments

Comments
 (0)