From: Richard Cheng <icheng@nvidia.com>
To: sashiko-reviews@lists.linux.dev
Cc: Alison Schofield <alison.schofield@intel.com>,
linux-cxl@vger.kernel.org
Subject: Re: [PATCH v2 3/3] cxl/hdm: Restore commit_end when decoder enumeration fails
Date: Thu, 16 Jul 2026 16:41:30 +0800 [thread overview]
Message-ID: <aliYaE7AMyHfF791@MWDK4CY14F> (raw)
In-Reply-To: <20260715215706.A76341F000E9@smtp.kernel.org>
On Wed, Jul 15, 2026 at 09:57:06PM +0800, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] Mixing goto-based error handling with scope-based cleanup helpers (`scoped_guard()`) in the same function.
> --
>
> --- Patch [3]: [PATCH v2 3/3] cxl/hdm: Restore commit_end when decoder enumeration fails ---
> commit fee00b887a5dc8f3c4c335d03db77d2ecce10947
> Author: Alison Schofield <alison.schofield@intel.com>
>
> cxl/hdm: Restore commit_end when decoder enumeration fails
>
> This commit restores commit_end to the none-committed baseline on the
> enumeration failure path so a subsequent probe can enumerate cleanly. It
> also protects the commit_end advance against concurrent readers in the
> DVSEC emulation path.
>
> > diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c
> > --- a/drivers/cxl/core/hdm.c
> > +++ b/drivers/cxl/core/hdm.c
>
> [ ... ]
>
> > @@ -1198,7 +1199,8 @@ static int devm_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm,
> > dev_warn(&port->dev,
> > "Failed to allocate decoder%d.%d\n",
> > port->id, i);
> > - return PTR_ERR(cxled);
> > + rc = PTR_ERR(cxled);
> > + goto err;
>
> [ ... ]
>
> > @@ -1220,17 +1223,23 @@ static int devm_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm,
> > "Failed to initialize decoder%d.%d\n",
> > port->id, i);
> > put_device(&cxld->dev);
> > - return rc;
> > + goto err;
> > }
> > rc = add_hdm_decoder(port, cxld);
> > if (rc) {
> > dev_warn(&port->dev,
> > "Failed to add decoder%d.%d\n", port->id, i);
> > - return rc;
> > + goto err;
> > }
> > }
> >
> > return 0;
> > +
> > +err:
> > + /* Reset to the none committed baseline for a fresh enumeration */
> > + scoped_guard(rwsem_write, &cxl_rwsem.region)
> > + port->commit_end = -1;
> > + return rc;
> > }
>
> [Severity: Medium]
> Does mixing goto-based error handling with scope-based cleanup helpers
> (scoped_guard) in the same function violate the cleanup subsystem guidelines?
>
> The documentation in include/linux/cleanup.h notes that usage of "goto"
> and cleanup helpers should never be mixed in the same function, because it
> creates confusing ownership semantics and can lead to bugs under future
> modifications.
>
> Should devm_cxl_enumerate_decoders() either be converted entirely to
> scope-based cleanup, or avoid using scoped_guard() in the error path?
>
Hi Alison,
I think this finding is real, at this point, decoder added by earlier loop
iterations are still registered until the caller's devres unwind runs.
So resetting commit_end here will create a window where those enable decoder
objects are still visible, but cxl_num_decoders_committed() tell us it's 0 there.
I think the commit_end reset should be ordered after the registered decoder are removed.
--Richard
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/cover.1784150131.git.alison.schofield@intel.com?part=3
>
prev parent reply other threads:[~2026-07-16 8:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 21:45 [PATCH v2 0/3] Harden HDM decoder enumeration Alison Schofield
2026-07-15 21:45 ` [PATCH v2 1/3] cxl/hdm: Reject switch decoder interleave ways that overflow targets Alison Schofield
2026-07-15 22:04 ` sashiko-bot
2026-07-16 8:49 ` Richard Cheng
2026-07-15 21:45 ` [PATCH v2 2/3] cxl/hdm: Make switch decoder target parsing endian-safe Alison Schofield
2026-07-16 8:45 ` Richard Cheng
2026-07-15 21:45 ` [PATCH v2 3/3] cxl/hdm: Restore commit_end when decoder enumeration fails Alison Schofield
2026-07-15 21:57 ` sashiko-bot
2026-07-16 8:41 ` Richard Cheng [this message]
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=aliYaE7AMyHfF791@MWDK4CY14F \
--to=icheng@nvidia.com \
--cc=alison.schofield@intel.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.