Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp355972imj; Sat, 16 Feb 2019 01:48:52 -0800 (PST) X-Google-Smtp-Source: AHgI3IaBdWuTFbU+beVvSzpUVQLTFJSW+6oUmMUXmawGSOvGpCae5BSSApQCdWkmmKl2eokHwzSp X-Received: by 2002:a62:445a:: with SMTP id r87mr13955882pfa.13.1550310532374; Sat, 16 Feb 2019 01:48:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550310532; cv=none; d=google.com; s=arc-20160816; b=XN4ibGGcVRY3M4YW6LJ9mC532s/h+HgAscJUj1IpmOXZl0tQqFIr3EaGVB3kbVzRxx A+p109njDLf0Ir7XusHZOnYHolMWk6kXWt+DPwTajgmHGxM+UXy3W/TJjVszb1YkS46W ThFLzpep0SWySEzn60o8mBg41FEnB4rgsRKIS75zAncRlCg1sb7S0HYukDpGyoiJOuAh mfyEuL675veGHVIFQIUDvYlefKVglBYmyRo+EW9cej7+X1Vd3xsiVf+aVifWFe5b8661 f2tekCXY5qPRkBF8Uxt2sfzT4ngpVGR0zIWaiMPm5PnWzl7vp1qXJfJbA31lzY/rdJiR Wt/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=jjGpWmojnHUt14UZi64MIH6xh6crUDPxGXrjBJAVrn0=; b=qFiwPtQmQkYbRdPIhRnLs6k/xmmOMhHGtfkqSIQN+h1Iy5bMylkGz8flChTJSKBHv+ fWYD0t0LRsTfCcQkaSYtumQhfJlbpXa6UUqNite6kxR27b+6QYtPePJEs3TbArpG1bWT Y4hIipS6hIk3cidjIpr+9Wmk++aN+Qu8qQBprBtFQOnrIcreCwr3XOSsD6ebxijeBzte 5DpTarNj8w9Bb7sRNGHBtKCgaAliYWnvzqwE1tHxlIp3zgk5/0yFGHdLec3BtHNxP8Qj 7r5nshiDra4HHFaeQewmVWvyS1bCJMHJAQmpbjeZp3udd9xUa9afLeHrF+0jNxw1Kdil AtCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TT+TsD1m; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m61si8200407plb.43.2019.02.16.01.48.36; Sat, 16 Feb 2019 01:48:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TT+TsD1m; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S2390369AbfBPAT0 (ORCPT + 99 others); Fri, 15 Feb 2019 19:19:26 -0500 Received: from mail-qk1-f201.google.com ([209.85.222.201]:41622 "EHLO mail-qk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730550AbfBPATZ (ORCPT ); Fri, 15 Feb 2019 19:19:25 -0500 Received: by mail-qk1-f201.google.com with SMTP id u197so9480855qka.8 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=fVIzQFaOIEuX+rmitd8nNro05a5XzAHnx4VLOu+xnTVBTrt/22yjp0vENPebF5fhd8 yYCVA5HXPHmt+okv0prHahn25Avx9Df8R2h5ARtXWZRxsExx+1B294qWdQbLa5vOf8yk Sv0LKNZlmvwKJl126DtsG8Mvp+6zIAQIp9GH8zlx4vwd44/bQndGncoU1s0BtJXAZ+SV s0JXbXO6Ir6Viurhds/UeFbeZt1tPZPn/Si8Tp1nt9s9uej6yk2mSlql5vGXO2OEcRB7 +sKY2a+kuCWLpNi5jxWIE9s6Bqf5uSaPXRqLDW2bYek39skr7KflwfUmvzMbQr9BYSUV WjIQ== X-Gm-Message-State: AHQUAuaORGvaWsIMTkGpbrilRmtN7CQomNZko7Plt3MLIZj3Is8z2+Z5 mt8ch5Oc1Qllu/P3F7WaYzxPsyvA/kN/ 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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) -- 2.21.0.rc0.258.g878e2cd30e-goog