Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp758722lqo; Fri, 17 May 2024 00:02:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW51yWwmPf8diNoNCUXedqZOPD+KuGVujY4w5sFVfKkqW42Io8LTQlpqnKWEhq0ZL9Xyr+GP6j1gCleRtqNNN2AFNiItSFmhEagUPXEpA== X-Google-Smtp-Source: AGHT+IEWC0cc2VdaGJ6IQhUdceKhkQ2kgnecGcgbID7DAQTpX2y575QczHXPmyuI7FyzpdGtkdGU X-Received: by 2002:a17:906:a99:b0:a59:aa68:99a0 with SMTP id a640c23a62f3a-a5a2d5819bbmr1377821366b.18.1715929375220; Fri, 17 May 2024 00:02:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715929375; cv=pass; d=google.com; s=arc-20160816; b=PynYvJ9yMqppKXHLyUicFLQBsl7lWe3SjeStvT3TE3TAk32ukI1RK8Er0aTWaYE5Qs jkQQWhQBNH++v4Sm4QmTxvFNbL4ZW68vorFdrHibKQPrM/cgzIQMRW3NPlY8TLCs7O0h 3hr2DqnLARJkjFUBx8V/RaER43iKOk0c24thtAfInsMOWNSIeSh6JkGtYLEE+PGJ6uy4 8YrI1DO7pRaRJOpjXLM+4rZWoa0YJpAeAtgr126A16DixeaNan+b/BQA7CqOANyJctij jLbAl963uaMB1KcwLgqJ0o5e9hNFCWzsSUhht3HAAuUX3zA9tPX1TNGdmlgIsvqybP0Q 5z7g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=EdfTodFm2OFLJ/9JBCUXk4QT9oTn5vS52O0Pgs8Cyqg=; fh=L5VuQopJS0EDt+4xhMNCg1PCykXrxKV65sjgXIGldxk=; b=nO8fsKm5P+5pmw63w9JngjP9DqK02y8vFN6KAZY/Edh1Y0Dc1RZTcS/0erENhgZ4g5 LoHZQluP+9J81h242OMlwiZMxVeabRgmak91dHXsYDV3KXgTja76YNVxUIGUChrTEAQl Xggtxa3CcWe2tch4YCzR7IM4I1GOHHrQOxe9z0/g5UsqQqfLhQ4sYiXpGDo7El1e4JOm bcdExLru+MrCq4sFLsX93o/nODcFSDFF9Tdd6spbqcXr8kKaKmByZ/1QTDaOi28xWDo5 NrSeThjMKhtAUkT9uc4WpkV1iY9CyVKC79jLzTUV8IR2ZhyIuazDEMZu0aQ1tTHyDEda g3bA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=DsR8dTEH; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-181775-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181775-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17bb1b66si911321266b.682.2024.05.17.00.02.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 00:02:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181775-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=DsR8dTEH; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-181775-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181775-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id EC0551F2176E for ; Fri, 17 May 2024 07:02:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F29415E85; Fri, 17 May 2024 07:02:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="DsR8dTEH" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C53E814A9F; Fri, 17 May 2024 07:02:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715929366; cv=none; b=K+YK0adrXvX4RL9xWyMLnuiL4GkbyMp8ZsfBB4kXBjtb8xwo9f7opmNioPH280K9saHsMQJ2qa1cji1blE2V86W4dX5qo2fKEmV+2HjefSw3PTcox7xFapO82rglqP/AZZb7MKZ/ZpyyltIsNrLa0T7ys5icL4xZJBS2lHmdWcw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715929366; c=relaxed/simple; bh=yfF8T0qSQyJNeBh2GE62uu/f4rsUpxn6cGIf7Wi5s6Y=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=WuYa11GCwDPbqFWvHeUnJH60ZnOPZuwpT2J8C+Z4RhXpMgwjiZTAW30u/H37MyglNSlJdi7SrhbXGWKWsK8/Q2edtO3upQhoRvkarSj70maLqi6GlawgOSsBmY4aP3C+tn0b2Vorl42qUCJrJyym/ucuM65DB5hmdWyACuqP484= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=DsR8dTEH; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44GKMq0H020849; Fri, 17 May 2024 07:02:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=qcppdkim1; bh=EdfTodF m2OFLJ/9JBCUXk4QT9oTn5vS52O0Pgs8Cyqg=; b=DsR8dTEHmUYrF3uGJq2W0+S e5NBd8hJWGy1UX7GxkEKX6ORcTAaTodP4A3UtQZv0ESKxqyYJP0mTB+HcJ07yfHN u9FUn1ghijsNsa8ebplg/7Hu1qVefE2Wnwdm680lEnjVb8zbDJOkWh7YVX0kLpMO QB0ZQ+j5noNKLKnwLu1ozH4fcE4HiU0hIjbDNo6tyF80djukRQPKsvQnPCbemZzC e3BetdMIaWPE81ml+tZ4AN39rmCwyiSW/lD/iw+IRMKAb8Qh8Yw9ikC6HxFWxMaQ hsjAPHb3houB46xYhAB+OUmd7YDs45+r+Kd19qP8gs7gl2T0pgo3AMRWHS7SMOg= = Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3y42kw082p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 May 2024 07:02:24 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 44H72M09007517 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 May 2024 07:02:22 GMT Received: from hu-jkona-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.1544.9; Fri, 17 May 2024 00:02:18 -0700 From: Jagadeesh Kona To: Sudeep Holla , Viresh Kumar , "Rafael J . Wysocki" , "Cristian Marussi" CC: , , , Taniya Das , "Ajit Pandey" , Imran Shaik , Vivek Aknurwar , Mike Tipton , Jagadeesh Kona Subject: [PATCH] cpufreq: scmi: Avoid overflow of target_freq in fast switch Date: Fri, 17 May 2024 12:31:57 +0530 Message-ID: <20240517070157.19553-1-quic_jkona@quicinc.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: VtqDQfNAvGcP8u5ca1Ejpm2-7TMNedd7 X-Proofpoint-ORIG-GUID: VtqDQfNAvGcP8u5ca1Ejpm2-7TMNedd7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-16_07,2024-05-15_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 malwarescore=0 mlxlogscore=831 phishscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 spamscore=0 adultscore=0 mlxscore=0 impostorscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405010000 definitions=main-2405170054 Conversion of target_freq to HZ in scmi_cpufreq_fast_switch() can lead to overflow if the multiplied result is greater than UINT_MAX, since type of target_freq is unsigned int. Avoid this overflow by assigning target_freq to u64 variable for converting it to HZ. Signed-off-by: Jagadeesh Kona --- drivers/cpufreq/scmi-cpufreq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c index 3b4f6bfb2f4c..42be87aebe6f 100644 --- a/drivers/cpufreq/scmi-cpufreq.c +++ b/drivers/cpufreq/scmi-cpufreq.c @@ -63,9 +63,9 @@ static unsigned int scmi_cpufreq_fast_switch(struct cpufreq_policy *policy, unsigned int target_freq) { struct scmi_data *priv = policy->driver_data; + u64 freq = target_freq; - if (!perf_ops->freq_set(ph, priv->domain_id, - target_freq * 1000, true)) + if (!perf_ops->freq_set(ph, priv->domain_id, freq * 1000, true)) return target_freq; return 0; -- 2.43.0