All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Richard Cheng" <icheng@nvidia.com>
Cc: linux-cxl@vger.kernel.org
Subject: Re: [PATCH v8 2/3] cxl/hdm: Allow zero sized HDM decoders
Date: Fri, 31 Jul 2026 07:01:58 +0000	[thread overview]
Message-ID: <20260731070158.A61051F00AC4@smtp.kernel.org> (raw)
In-Reply-To: <20260731064902.34127-3-icheng@nvidia.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] cxl_dpa_free() silently early-returns on zero-sized decoders, failing to release the DPA tracking resource and permanently locking port->hdm_end, breaking LIFO teardown.
--

--- Patch [2]: [PATCH v8 2/3] cxl/hdm: Allow zero sized HDM decoders ---
commit d92ffa9b7fbe4708b46c314f7b9ca98c30df149a
Author: Richard Cheng <icheng@nvidia.com>

cxl/hdm: Allow zero sized HDM decoders

This commit updates the CXL core to allow committing an HDM decoder
with a size of 0, treating them as first-class decoders backed by a
kmalloc'd resource. It updates accounting and guards various paths
that an empty decoder cannot serve.

> diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c
> index 0c80b76a5f9b4..3b3cfa0f25074 100644
> --- a/drivers/cxl/core/hdm.c
> +++ b/drivers/cxl/core/hdm.c

[ ... ]

> @@ -545,7 +572,7 @@ int cxl_dpa_free(struct cxl_endpoint_decoder *cxled)
>  	struct device *dev = &cxled->cxld.dev;
>  
>  	guard(rwsem_write)(&cxl_rwsem.dpa);
> -	if (!cxled->dpa_res)
> +	if (cxled_empty(cxled))
>  		return 0;

[Severity: High]
Does this early return leak the zero-sized DPA reservation and break the
LIFO teardown order?

When a zero-sized decoder is initialized, __cxl_dpa_reserve() allocates a
zero-sized resource and increments port->hdm_end.

If a user later attempts to free this DPA (for example, by writing 0 to the
dpa_size sysfs attribute), cxled_empty() will evaluate to true here because
the resource size is 0. This bypasses devm_cxl_dpa_release(), meaning the
kmalloc'd resource is never freed and port->hdm_end is never decremented.

Since port->hdm_end remains stuck on this decoder, does this permanently
block the freeing of any prior decoders on the same port due to the strict
LIFO teardown requirements?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260731064902.34127-1-icheng@nvidia.com?part=2

  reply	other threads:[~2026-07-31  7:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-31  6:48 [PATCH v8 0/3] Support zero-sized HDM decoders Richard Cheng
2026-07-31  6:49 ` [PATCH v8 1/3] cxl/region: Simplify poison_by_decoder() error handling Richard Cheng
2026-07-31  7:04   ` sashiko-bot
2026-07-31  6:49 ` [PATCH v8 2/3] cxl/hdm: Allow zero sized HDM decoders Richard Cheng
2026-07-31  7:01   ` sashiko-bot [this message]
2026-07-31  6:49 ` [PATCH v8 3/3] tools/testing/cxl: Enable zero sized decoders under hb0 Richard Cheng

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=20260731070158.A61051F00AC4@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=icheng@nvidia.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.