From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 47C5D1ED38 for ; Tue, 25 Jul 2023 11:35:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA8CBC433CC; Tue, 25 Jul 2023 11:35:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1690284930; bh=CChSYG2HWlH9cnErpv6jvCtBeYsLf6GPTBAwsh42+4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tl6cRbORX61QsSCglfVbd8SOXxBxGBMAARr9yUTMhyQgB2fyYSxDkmQpEvQdmgJgV 1oV4ddVcS9K9BBP0Sa2t9xHISFDDv+fqTrnTAsW8f8OnRLsIcx1dlpLjMtYxVfjOI6 jgJVChDCJ7P00qMJAIQRpbZ6uwxVI3DOIeJxWu+g= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Nikita Zhandarovich , Ulf Hansson , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 5.4 022/313] PM: domains: fix integer overflow issues in genpd_parse_state() Date: Tue, 25 Jul 2023 12:42:55 +0200 Message-ID: <20230725104522.092732645@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230725104521.167250627@linuxfoundation.org> References: <20230725104521.167250627@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Nikita Zhandarovich [ Upstream commit e5d1c8722083f0332dcd3c85fa1273d85fb6bed8 ] 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 Acked-by: Ulf Hansson Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- 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 edb791354421b..5be76197bc361 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2596,10 +2596,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.39.2