From: "David E. Box" <david.e.box@linux.intel.com>
To: "Hans de Goede" <hansg@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
platform-driver-x86@vger.kernel.org
Cc: "David E. Box" <david.e.box@linux.intel.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/6] platform/x86/intel/pmt/discovery: Avoid WARN for malformed tables
Date: Fri, 30 Oct 2026 18:29:34 -0700 [thread overview]
Message-ID: <20261031012939.377995-3-david.e.box@linux.intel.com> (raw)
In-Reply-To: <20261031012939.377995-1-david.e.box@linux.intel.com>
The feature table contents are supplied by the device, so an invalid table
size is an expected probe error. WARN() is not appropriate for malformed
device data because systems with panic_on_warn set will panic.
Use dev_err_probe() instead. This preserves the diagnostic and -EINVAL
return while being a better fit for the probe failure path.
Fixes: d9a078809356 ("platform/x86/intel/pmt: Add PMT Discovery driver")
Signed-off-by: David E. Box <david.e.box@linux.intel.com>
---
drivers/platform/x86/intel/pmt/discovery.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/x86/intel/pmt/discovery.c b/drivers/platform/x86/intel/pmt/discovery.c
index 47a4def6e6b9..143d2b3be562 100644
--- a/drivers/platform/x86/intel/pmt/discovery.c
+++ b/drivers/platform/x86/intel/pmt/discovery.c
@@ -440,8 +440,9 @@ pmt_feature_get_feature_table(struct pmt_features_priv *priv,
size = sizeof(*header) + FEAT_ATTR_SIZE(header->attr_size) +
PMT_GUID_SIZE(header->num_guids);
res_size = resource_size(&res);
- if (WARN(size > res_size, "Bad table size %zu > %pa", size, &res_size))
- return -EINVAL;
+ if (size > res_size)
+ return dev_err_probe(priv->dev, -EINVAL,
+ "Bad table size %zu > %pa\n", size, &res_size);
/* Get the feature attributes, including capability fields */
tbl_offset += sizeof(*header);
--
2.43.0
next prev parent reply other threads:[~2026-10-31 1:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-31 1:29 [PATCH 0/6] platform/x86/intel: Harden PMT discovery against malformed device data David E. Box
2026-10-31 1:29 ` [PATCH 1/6] platform/x86/intel/pmt/discovery: Bound attr_size against feature_table capacity David E. Box
2026-10-31 1:29 ` David E. Box [this message]
2026-10-31 1:29 ` [PATCH 3/6] platform/x86/intel/pmt/discovery: Validate feature id before use David E. Box
2026-10-31 1:29 ` [PATCH 4/6] platform/x86/intel/vsec: Validate discovery table bounds against the BAR David E. Box
2026-10-31 1:29 ` [PATCH 5/6] platform/x86/intel/pmt/discovery: Validate feature table " David E. Box
2026-10-31 1:29 ` [PATCH 6/6] platform/x86/intel/pmt: Validate telemetry regions " David E. Box
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261031012939.377995-3-david.e.box@linux.intel.com \
--to=david.e.box@linux.intel.com \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.