Message ID | 20240131113713.74779-2-rui.zhang@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-46367-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1824955dyb; Wed, 31 Jan 2024 03:39:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IFc29zvenFnWxG3pI0dipYzGH7dBIMQOqNiDrQhtws5O9Sx2m7cYSC+a2q4Dhv9qjfXo1Bx X-Received: by 2002:a17:906:a88f:b0:a29:4267:ac9 with SMTP id ha15-20020a170906a88f00b00a2942670ac9mr883866ejb.52.1706701172544; Wed, 31 Jan 2024 03:39:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706701172; cv=pass; d=google.com; s=arc-20160816; b=tWVsJo/GSMPUfoA02kP+kwIMJhb8/MIDH8MyzMfVjleNOkJjojmLXc/99f1mK2Orj0 PIW8UvZSj2S29yyOYHYhSPmO/Bb7B/OcN6+uAsm/KKjbILEetsB6qq63I76oQ0a5L/+V x1WyN6fPPD717fEbn8T9BHEV/QI6989ODW+mUK5JfLuMb57+ZdVxUxhBPH32sXirJ0Yp LMLR3K9gMEnmoTgL0RxDP67QslQNV/q4RhfoCfn8/fSN0ztpwlgWQG3vEveVdwoXY1lG /6Z+77C295/ekpfWZIPVxJGFqtCCTIfX80pQ1rQt0uikGLrCYLr5a5yfPqvXjuMXzdKO z2Pw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=cfci4fakwDjALMhDX4AobiSM7fw1s9fhbnOIAXEp3mU=; fh=201txUgYmkwg4q62p+vn0Cz2GFsbH9n+A8rcw8Ieh8Y=; b=zE1N7rn7ZKZKtNijlUXouRzKQ68dKe2g+XzxSR5J2vf2fSoM5tUJ0KLsYyfsW8t4YN woRnhwv8Wwvnwx4gizgxm5eFTBbcPareCIii5unuVe1FBfWoLOglSBXrOGt6O6rl+GsU hBrDRp6M3Zt6UtTmJEevyf+CcKCaLQ/YVi37fRDWZL1UUtvpSjZLdKekGB6RnN2kfCxF ghHS0GzSy3RregTzEiNWhi8neRo/yYUX9AVOTD9tCjUJflFJIcF3denwr29SAikuyvfM PHgztqOOrs8YnXoY5mmaapiQ0fc66zQlhfDqJexE41pHKqiBfppgXW5LXW9rX5wT05De XhKw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gHWjYalG; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-46367-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46367-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCU2T/OOuVvsi01SB2x76VN0CHhiRIwL/Ke+8ze1Iy0z+b7tgplAkbKnIZtEBU5MOPqrG1qsfZwnmyV9K5P/ASAViblxDQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id md7-20020a170906ae8700b00a353a6bce7csi4725886ejb.325.2024.01.31.03.39.32 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 03:39:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46367-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gHWjYalG; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-46367-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46367-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 217B41F24D5A for <ouuuleilei@gmail.com>; Wed, 31 Jan 2024 11:39:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5377B7D412; Wed, 31 Jan 2024 11:37:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="gHWjYalG" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (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 0929D6D1D2; Wed, 31 Jan 2024 11:37:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706701050; cv=none; b=K5XPhY5RrIEolWrGIExgV1U+O5MKd1X8eBPWLBq6Kfz6eD7cLF/2S/V+Y36WD5EBNKsLy/0AEtpa+DfXQKUE2DfIYOeuS1wpqkP4ZrfWJvXNv767A548zXgJ7bC4ji+HxcCkhrjZIBOCvtgKvBCBx8iMyLrIT3ebokVeMZY2uqc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706701050; c=relaxed/simple; bh=GvAqwQ4KOZBh0mXfOdAbuk8oUfo2FkUF0mPuB57A4+4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HAS3gtaaSCo5bfUJNiw/Mb2ZeY6KrUNaYdxL/vP4EEBXxIK/ByeOAdO40dZ0GScMvfW2EJj2OXiaPgkngrSRDn3hHjx+uxj9UbtaTwPUVBn2Odlp84pVuHItdroRmxTo654iFw2uru6XpD/y58AuzCHAUgszLEu+KCABt4zLxFo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=gHWjYalG; arc=none smtp.client-ip=198.175.65.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706701048; x=1738237048; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GvAqwQ4KOZBh0mXfOdAbuk8oUfo2FkUF0mPuB57A4+4=; b=gHWjYalGxYdoeFDEzjBJyiRO2S3fDrmTNbr9PoYEogwCfTR21QUZe23H pQ/Oorsi+Xgaj9TAjZJYwCIN8+CcP51CZlqLoj0vDPLRVf4NZcXq93TL5 y+XrNusNotfgKq2MKdAd9GVCpNvNS/HpDBeddzlsOYqmg6PY05Cl6g08L lnXQPT2fdGUDbqecj/GkU+eIg73TBlLpLWqdTs4Ji2HMRnMzBd+dKgeIq 87RLWT2gh4QEyHcAKiJeIjwNfl7+RCmFS/I1h1Xg7sXEG/8+MUqg4bi2n IXlKffMmwFw8qBDIZU7jh4L/WeKri7nblnsiFZBwiszBbgQcX1z+iYN3h w==; X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="3441622" X-IronPort-AV: E=Sophos;i="6.05,231,1701158400"; d="scan'208";a="3441622" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2024 03:37:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="788542472" X-IronPort-AV: E=Sophos;i="6.05,231,1701158400"; d="scan'208";a="788542472" Received: from puhongt-mobl2.ccr.corp.intel.com (HELO rzhang1-mobl7.ccr.corp.intel.com) ([10.255.29.147]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2024 03:37:24 -0800 From: Zhang Rui <rui.zhang@intel.com> To: rafael.j.wysocki@intel.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH 1/6] powercap: intel_rapl: Fix a NULL pointer dereference bug Date: Wed, 31 Jan 2024 19:37:08 +0800 Message-Id: <20240131113713.74779-2-rui.zhang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240131113713.74779-1-rui.zhang@intel.com> References: <20240131113713.74779-1-rui.zhang@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789605888624760276 X-GMAIL-MSGID: 1789605888624760276 |
Series |
powercap: intel_rapl: Fixes and new platform enabling
|
|
Commit Message
Zhang, Rui
Jan. 31, 2024, 11:37 a.m. UTC
A NULL pointer dereference bug is triggered when probing MMIO RAPL
driver on platforms with CPU ID not listed in intel_rapl_common CPU
model list.
This is because the intel_rapl_common module still probes on such
platforms even if 'defaults_msr' is not set after commit 1488ac990ac8
("powercap: intel_rapl: Allow probing without CPUID match"). Thus the
MMIO RAPL rp->priv->defaults is NULL when registering to RAPL framework.
Fix the problem by adding sanity check to ensure rp->priv->rapl_defaults
is always valid.
Fixes: 1488ac990ac8 ("powercap: intel_rapl: Allow probing without CPUID match")
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Cc: <stable@vger.kernel.org>
---
drivers/powercap/intel_rapl_common.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/powercap/intel_rapl_common.c b/drivers/powercap/intel_rapl_common.c index 2feed036c1cd..1a739afd47d9 100644 --- a/drivers/powercap/intel_rapl_common.c +++ b/drivers/powercap/intel_rapl_common.c @@ -759,6 +759,11 @@ static int rapl_config(struct rapl_package *rp) default: return -EINVAL; } + + /* defaults_msr can be NULL on unsupported platforms */ + if (!rp->priv->defaults || !rp->priv->rpi) + return -ENODEV; + return 0; }