From: Dave Jiang <dave.jiang@intel.com>
To: linux-cxl@vger.kernel.org
Cc: dave@stgolabs.net, jic23@kernel.org, alison.schofield@intel.com,
djbw@kernel.org
Subject: [PATCH 1/2] cxl/pci: Fix the incorrect check of pci_read_config_word() return
Date: Wed, 3 Jun 2026 11:57:51 -0700 [thread overview]
Message-ID: <20260603185752.4149725-2-dave.jiang@intel.com> (raw)
In-Reply-To: <20260603185752.4149725-1-dave.jiang@intel.com>
pci_read_config_word() returns PCIBIOS_* status on error which are
positive values. The check should be for non-zero values to indicate
error. Fix cxl_set_mem_enable() to check for non-zero return value
instead of negative value.
While fixing this, also convert the error to negative errno value when
returning on error path.
Fixes: 34e37b4c432c ("cxl/port: Enable HDM Capability after validating DVSEC Ranges")
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
drivers/cxl/core/pci.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c
index d1f487b3d809..43885c59a7f2 100644
--- a/drivers/cxl/core/pci.c
+++ b/drivers/cxl/core/pci.c
@@ -187,8 +187,8 @@ static int cxl_set_mem_enable(struct cxl_dev_state *cxlds, u16 val)
int rc;
rc = pci_read_config_word(pdev, d + PCI_DVSEC_CXL_CTRL, &ctrl);
- if (rc < 0)
- return rc;
+ if (rc)
+ return pcibios_err_to_errno(rc);
if ((ctrl & PCI_DVSEC_CXL_MEM_ENABLE) == val)
return 1;
@@ -196,8 +196,8 @@ static int cxl_set_mem_enable(struct cxl_dev_state *cxlds, u16 val)
ctrl |= val;
rc = pci_write_config_word(pdev, d + PCI_DVSEC_CXL_CTRL, ctrl);
- if (rc < 0)
- return rc;
+ if (rc)
+ return pcibios_err_to_errno(rc);
return 0;
}
--
2.54.0
next prev parent reply other threads:[~2026-06-03 18:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 18:57 [PATCH 0/2] cxl/pci: Fix the incorrect check of pci_config_read/write*() returns Dave Jiang
2026-06-03 18:57 ` Dave Jiang [this message]
2026-06-04 10:45 ` [PATCH 1/2] cxl/pci: Fix the incorrect check of pci_read_config_word() return Richard Cheng
2026-06-04 16:17 ` Alison Schofield
2026-06-03 18:57 ` [PATCH 2/2] cxl/pci: Convert PCIBIOS errors to errno on DVSEC config accesses Dave Jiang
2026-06-04 10:45 ` Richard Cheng
2026-06-04 16:46 ` Alison Schofield
2026-06-04 10:17 ` [PATCH 0/2] cxl/pci: Fix the incorrect check of pci_config_read/write*() returns Jonathan Cameron
2026-06-04 10:30 ` Richard Cheng
2026-06-04 10:51 ` Richard Cheng
2026-06-04 15:58 ` Dave Jiang
2026-06-04 16:10 ` Dave Jiang
2026-06-04 15:57 ` Dave Jiang
2026-06-04 16:19 ` Alison Schofield
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=20260603185752.4149725-2-dave.jiang@intel.com \
--to=dave.jiang@intel.com \
--cc=alison.schofield@intel.com \
--cc=dave@stgolabs.net \
--cc=djbw@kernel.org \
--cc=jic23@kernel.org \
--cc=linux-cxl@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox