From patchwork Sat Feb 16 00:19:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 10816103 X-Patchwork-Delegate: andy.shevchenko@gmail.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 99FE417D5 for ; Sat, 16 Feb 2019 00:19:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8979E2FC97 for ; Sat, 16 Feb 2019 00:19:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D6E62FC9F; Sat, 16 Feb 2019 00:19:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 295B72FC97 for ; Sat, 16 Feb 2019 00:19:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730591AbfBPATZ (ORCPT ); Fri, 15 Feb 2019 19:19:25 -0500 Received: from mail-qt1-f202.google.com ([209.85.160.202]:36364 "EHLO mail-qt1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726377AbfBPATZ (ORCPT ); Fri, 15 Feb 2019 19:19:25 -0500 Received: by mail-qt1-f202.google.com with SMTP id p5so10694264qtp.3 for ; Fri, 15 Feb 2019 16:19:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=jjGpWmojnHUt14UZi64MIH6xh6crUDPxGXrjBJAVrn0=; b=TT+TsD1myHEzF7m8KRiLYBfIw4r9DrAEkHKInT4/cVReHzVS0zsB9jn31ewME94Y8N TAgQ2DmCwR8s2qJ25G3urS5uAG/uzRM8qBkrck7zfz3o+CcGKBp62dbkUDrCbyQdJ18o aCmHWCCFWQ2CTQr0Nx6MURyUqQ04TUHsf9JvH2n1qaVzjXm52qHp8fuHtlojd+MEwp/8 CpHQDpWB5ufpOpwyMxb7z0UgGdEGyqXNbW2WE1mbaC7iBJW4uzuTR8RQvfBGPkR4dG1o oc9dKw9aFHgcc2qGeroDepBV1OmVZkYqlGJYvAfBtFD5DrYOJtIdiJZOgJoYM4ZcWc+B QqLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=jjGpWmojnHUt14UZi64MIH6xh6crUDPxGXrjBJAVrn0=; b=KviZQ+4yQev606ecxc0hgu2wlCMdeBiW8/6rI5qnp5Kj4QHt2OLtIWuh1KT2fwFMwq 9XXqMBegjhcnIVbsRrN/WJHrkWin0hnQbuQvIUPMNKwqInGDFkoaQTby9mkRBR5rxCj4 EpLrJ7PvL5gRpj4ClbXhL8ZRzji0tq/J+733iZDsrrOazmPir4t/ZrgY0SXEUPixfYYk lLAMyFH+dPnGqBnDCBO2KMrY/keuSoSruYy7DN5fGorBkF0SXXiKRy9FiuRaL5Po2fco TW6SjNhSOjaUVXtjloAn5p9M6YESGDJwujJvg+qAEOY0fhioZ3oOpwHVjnEVUap8xcCP wBKA== X-Gm-Message-State: AHQUAubY5ajLtKPwo8/SuSYw/8+CrIo1ZTOQcvmqnsBUXSuXB9xMpT4Z XV2rBa27rMZnb1MPKvWWQkky6yWUZ6JE X-Google-Smtp-Source: AHgI3IaoKYI6JPVgWn3AJawhXw9QwnXzkC1DmguPZBh/XMrRvnfNQ2HfOAs5mHBFNt0SuZ4W9pYX44hEuPBF X-Received: by 2002:a0c:b996:: with SMTP id v22mr6879761qvf.2.1550276364715; Fri, 15 Feb 2019 16:19:24 -0800 (PST) Date: Fri, 15 Feb 2019 16:19:20 -0800 Message-Id: <20190216001920.178053-1-rajatja@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.21.0.rc0.258.g878e2cd30e-goog Subject: [PATCH] platform/x86: intel_pmc_core: Avoid a u32 overflow From: Rajat Jain To: Rajneesh Bhardwaj , Vishwanath Somayaji , Darren Hart , Andy Shevchenko , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Cc: rajatxjain@gmail.com, Rajat Jain Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The register (SLP_S0_RES) at offset slp_s0_offset is a 32 bit register. The pmc_core_adjust_slp_s0_step() could overflow the u32 value while returning it after adjusting the step. Thus change to u64, this is already accounted for in debugfs attribute (that wants to output a 64 bit value). Signed-off-by: Rajat Jain Acked-by: Rajneesh Bhardwaj --- drivers/platform/x86/intel_pmc_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c index 22dbf115782e..f90f4dd25151 100644 --- a/drivers/platform/x86/intel_pmc_core.c +++ b/drivers/platform/x86/intel_pmc_core.c @@ -328,9 +328,9 @@ static inline void pmc_core_reg_write(struct pmc_dev *pmcdev, int writel(val, pmcdev->regbase + reg_offset); } -static inline u32 pmc_core_adjust_slp_s0_step(u32 value) +static inline u64 pmc_core_adjust_slp_s0_step(u32 value) { - return value * SPT_PMC_SLP_S0_RES_COUNTER_STEP; + return (u64)value * SPT_PMC_SLP_S0_RES_COUNTER_STEP; } static int pmc_core_dev_state_get(void *data, u64 *val)