All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: linux-cxl@vger.kernel.org
Cc: Dave Jiang <dave.jiang@intel.com>
Subject: [PATCH] cxl/hdm: Avoid NULL deref when component registers are missing
Date: Wed, 29 Mar 2023 14:35:43 -0700	[thread overview]
Message-ID: <168012574357.221280.5001364964799725366.stgit@dwillia2-xfh.jf.intel.com> (raw)

The cxl_port driver attempts to support endpoint devices that do not
advertise a component register block, but by inspection
devm_cxl_setup_hdm() passes a NULL @crb to helper functions that should
be skipped.

Return early and skip setting target_count since that is only relevant
for switch decoders, not endpoint decoders.

Fixes: 757f6448b100 ("cxl/hdm: Fix double allocation of @cxlhdm")
Tested-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 drivers/cxl/core/hdm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c
index 5293fe13fce3..cc123996b1a4 100644
--- a/drivers/cxl/core/hdm.c
+++ b/drivers/cxl/core/hdm.c
@@ -123,7 +123,7 @@ struct cxl_hdm *devm_cxl_setup_hdm(struct cxl_port *port,
 	crb = ioremap(port->component_reg_phys, CXL_COMPONENT_REG_BLOCK_SIZE);
 	if (!crb && info && info->mem_enabled) {
 		cxlhdm->decoder_count = info->ranges;
-		cxlhdm->target_count = info->ranges;
+		return cxlhdm;
 	} else if (!crb) {
 		dev_err(dev, "No component registers mapped\n");
 		return ERR_PTR(-ENXIO);


             reply	other threads:[~2023-03-29 21:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-29 21:35 Dan Williams [this message]
2023-03-29 23:59 ` [PATCH] cxl/hdm: Avoid NULL deref when component registers are missing Dave Jiang
2023-03-30 17:19 ` Jonathan Cameron
2023-03-30 18:19   ` Dan Williams
2023-03-30 18:27     ` Jonathan Cameron
2023-03-30 18:49       ` Dan Williams
2023-03-30 19:04         ` Jonathan Cameron

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=168012574357.221280.5001364964799725366.stgit@dwillia2-xfh.jf.intel.com \
    --to=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --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 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.