Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4378190rwd; Tue, 30 May 2023 04:47:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6lMPk7JXrXqODe+5Vp5L7MaPYYaUzzhGrNstDfsQQFnQBWUI2cmugY0ACgm9JT4WxXyvRk X-Received: by 2002:a17:90a:9f96:b0:255:5d65:3a86 with SMTP id o22-20020a17090a9f9600b002555d653a86mr2268823pjp.8.1685447254436; Tue, 30 May 2023 04:47:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685447254; cv=none; d=google.com; s=arc-20160816; b=YLQwsGwcscXVMq62rhGBMj6Ue9Nhxr/vlka2Pb9iNnrsPfxZT0y0SBq4zRNQAAz91x EdEsmzKf/0BoeghO+mhmXVaqVBDiDt2kY+yi9dLuivvRa3vuFK64UB96acqM1xiWOE0x 6dd88XJKQGNF7M9nmNxwA66Oq6zDmDZJUNJFdkQVLZT4CVCSOz5t0IFAOadxiFif+YDF 962jJlOHUygWylXLxh5Te94oNFUx6UX6xEE9ZcxhqYNopGSeDB8QoNDiqbud9W1kJxK5 FO6Wk4HiI+tCWOF3J5k3t1zkryQydOEtIePjdNd6eO6JwfeMedegGNCcD7holQXkg6WN UuIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=X9Fa1azB0PvxCnVWP8BiPunu4QSKYBQpUml6svSnRR4=; b=BBqA3ETm8cB4fZPszZa1EhIaXK3o+ZLN6hdwRK5sGhpyW2Bk0PiVPFNx7i2MU+V1OJ h4LMy5C+yE01VYbp3ke2TYHoM/KSN7/7zuFiT8+t0I06n9mjE79Nq+vZ9dTRjWoFTOve 7X73eCP+3AajfgEn/zKlw8V2dAsDplqxwup4/rv3uly/TxfDwHI/nEHkSuYX5WgisfKS y2LhmvDauKsklr2LW18iCHcCTPmod8i5t3DJdvw/ZsrkjLW8arL7VFBSpS6obfL2JsRP 0CQ6aiYNbFUO6HRLYNikIzSf+vyoZq8t720IquZABzxfVYAQsGT2DCiuwJOCzRZEto/a 783Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=tBbXFhsb; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z22-20020a637e16000000b0053b29394937si1445853pgc.816.2023.05.30.04.47.21; Tue, 30 May 2023 04:47:34 -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=@google.com header.s=20221208 header.b=tBbXFhsb; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231219AbjE3LnR (ORCPT + 99 others); Tue, 30 May 2023 07:43:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230500AbjE3LnI (ORCPT ); Tue, 30 May 2023 07:43:08 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2060FE for ; Tue, 30 May 2023 04:42:40 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-ba83a9779f3so8521744276.1 for ; Tue, 30 May 2023 04:42:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685446960; x=1688038960; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=X9Fa1azB0PvxCnVWP8BiPunu4QSKYBQpUml6svSnRR4=; b=tBbXFhsb+KwoE9oe/RBk2v9mdJuTTIDySqRMyshEKtOzMZvFQaKqltj5sHLfNCbB7U DAAnKAtemaLVdaOI4iW473fBsrZybhyclZ+xr5O5b5ENY90G32ktqV0H86QR+iIXtzHZ OeZMWLokaN5xEqQJSKTtN5JZAGE0sJsN67LbpXNt3j89caN3+QHCC3fheu7jptCiaE1N zXmwIAk8D8alYIKgLnyC5NuPITFrGAqUPWD9shoJve99mTL4DpTjJD0+CZkCSk1p4Kn/ fzz2nq26+v2YkNnOA9jUr65xWuXorZL00/yxEw6yG9oS9pifrM1lHyzOIblXi11t1KVx mWcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685446960; x=1688038960; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=X9Fa1azB0PvxCnVWP8BiPunu4QSKYBQpUml6svSnRR4=; b=L66VgJLPUOp4ycaS+N6HVb9FUldnf2d9U9nt1MH/FZOYQxXQihX8YYc3CTDp4VJRvc Nv1LtdE0DprdIRiLac4j1DYe67yrxjb5h8zlp0UurUtNvvMB2vJ6ditk2GBji9wKVZOv NdxOOCTR/cvLsAQv4KdlIC4C2NS4uXzxSVDxixJxcpkHy48vIi1OyzXd/94yYMyhool8 2HWuA9mWkJGvvng+g7O5WQIUJsgrPvRFkEc4EwnUefOtr9jCAGvY7OifXtkRYJB8pwL+ XA0HIGKbzRkcCsvtnMs9lM+2A31BzEps7wAXGI14AHA3esc2IJu/WkFwYfUsAEGD3xzg Z/Iw== X-Gm-Message-State: AC+VfDyVMKdn8CnluwEhhM64NmH86zvhouQAuIlIYE/ehsqCdbSXdj2a Qq0UslqCbnqvY+zbUyUsKZT4AxgOzn07zGPk7Q== X-Received: from yimingtseng2023.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:94c]) (user=yimingtseng job=sendgmr) by 2002:a25:d88:0:b0:ba8:373e:acf1 with SMTP id 130-20020a250d88000000b00ba8373eacf1mr1217056ybn.12.1685446959912; Tue, 30 May 2023 04:42:39 -0700 (PDT) Date: Tue, 30 May 2023 11:42:16 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog Message-ID: <20230530114216.1420790-1-yimingtseng@google.com> Subject: [PATCH] PM: domains: fix overflow in genpd_parse_state From: YiMing Tseng To: "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson , Len Brown , Pavel Machek , Greg Kroah-Hartman Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, marscheng@google.com, YiMing Tseng Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL 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 Add type casters to prevent 32-bit overflow before assigning to s64 variables. It allows full 32-bit range support for latency and residency. Signed-off-by: YiMing Tseng --- 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..26a04cd8d8dc 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 = (s64)1000 * 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 = (s64)1000 * exit_latency; + genpd_state->power_off_latency_ns = (s64)1000 * entry_latency; genpd_state->fwnode = &state_node->fwnode; return 0; -- 2.41.0.rc0.172.g3f132b7071-goog