Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp5379135rwe; Tue, 18 Apr 2023 06:13:38 -0700 (PDT) X-Google-Smtp-Source: AKy350bjQvgg3Utry34t5P+9spnK6z8w/6CZmf4kD91TULteV6dN8le8zka/wOFVAx5hdhAERROV X-Received: by 2002:a17:90b:3a8e:b0:247:5bb4:f445 with SMTP id om14-20020a17090b3a8e00b002475bb4f445mr1987244pjb.29.1681823618591; Tue, 18 Apr 2023 06:13:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681823618; cv=none; d=google.com; s=arc-20160816; b=GXgfu9hxmIDqZoPEZmNWwWLd2HLn33PtmummqCc5sJ/mySRMoVBOs46KzF/ou96VLf 4oigUZLQFSiJ4kdV6mb/zFBJhQ6g1pyMROWG6+0GNaC0bKMdSHSWs3cSvAU6hTbQ7ZFN jXTgrGc0lVvKHaoI1wpccNwoUwBLZNt+YNjr0AyhFtqXfDbGMseIdBNTrszAwPx/zZxf BfDhonOXyZbyCaOqPqV17xl6NX48+7t61fyZ+53/0u+C/aHsrFN0zssMIy+pXFSBbYfS faLIDcdfEm3Uq3M//dP8RsW3Gbcacptty7PE7QW42MlKUlttmstSMu1mPYXvIPbKXBjr NBqA== 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; bh=PFutZKB789lgbJIHVExt/58X9sr6xXt+vyymG8I337o=; b=0shAKVYqnyrq19GkK7NLsRuSSQyFRStGdEBMwLmA2sSnj8lEex/gDq+HV4xP7rhz/h o5ORM26QcywXhTDbjPuz5wslLKeCC2sRyGKgA6/EHXd4POQzvVfrqOJ9oYGrxQvNTxai IfyMniPSUHrZup/xwwu7K8dYPfREJt28mym3lZLHkppir6Yg5WZ3fjXUdI2cck6zfX5v UGIcDkr/VDtZLMhdE6+kkzp+NqpiQsosHzUI8QO85VJrgoZ8lLru30P2R45RCQNEWg1P VL3RaZlJ/5JwJjsnRGkPxS/VgJ+x5r+Blpv19xr8krozc85BjoBPYm7h2xhI5m9a+hlF l23A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h8-20020a631208000000b0051b36b15cbesi13559072pgl.214.2023.04.18.06.13.25; Tue, 18 Apr 2023 06:13:38 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232294AbjDRNIA (ORCPT + 99 others); Tue, 18 Apr 2023 09:08:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232203AbjDRNHx (ORCPT ); Tue, 18 Apr 2023 09:07:53 -0400 Received: from exchange.fintech.ru (e10edge.fintech.ru [195.54.195.159]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F63115A25; Tue, 18 Apr 2023 06:07:50 -0700 (PDT) Received: from Ex16-01.fintech.ru (10.0.10.18) by exchange.fintech.ru (195.54.195.159) with Microsoft SMTP Server (TLS) id 14.3.498.0; Tue, 18 Apr 2023 16:07:47 +0300 Received: from localhost (10.0.253.138) by Ex16-01.fintech.ru (10.0.10.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Tue, 18 Apr 2023 16:07:47 +0300 From: Nikita Zhandarovich To: "Rafael J. Wysocki" CC: Nikita Zhandarovich , Kevin Hilman , Ulf Hansson , Len Brown , Pavel Machek , Greg Kroah-Hartman , , , Subject: [PATCH] PM: domains: fix integer overflow issues in genpd_parse_state() Date: Tue, 18 Apr 2023 06:07:43 -0700 Message-ID: <20230418130743.67024-1-n.zhandarovich@fintech.ru> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.0.253.138] X-ClientProxiedBy: Ex16-02.fintech.ru (10.0.10.19) To Ex16-01.fintech.ru (10.0.10.18) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 Currently, while calculating residency and latency values, right operands may overflow if resulting values are big enough. To prevent this, albeit unlikely case, play it safe and convert right operands to left ones' type s64. Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE. Fixes: 30f604283e05 ("PM / Domains: Allow domain power states to be read from DT") Signed-off-by: Nikita Zhandarovich --- drivers/base/power/domain.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 32084e38b73d..51b9d4eaab5e 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2939,10 +2939,10 @@ static int genpd_parse_state(struct genpd_power_state *genpd_state, err = of_property_read_u32(state_node, "min-residency-us", &residency); if (!err) - genpd_state->residency_ns = 1000 * residency; + genpd_state->residency_ns = 1000LL * residency; - genpd_state->power_on_latency_ns = 1000 * exit_latency; - genpd_state->power_off_latency_ns = 1000 * entry_latency; + genpd_state->power_on_latency_ns = 1000LL * exit_latency; + genpd_state->power_off_latency_ns = 1000LL * entry_latency; genpd_state->fwnode = &state_node->fwnode; return 0; -- 2.25.1