From: Gregory Price <gourry@gourry.net>
To: Jonathan Cameron <jonathan.cameron@huawei.com>
Cc: Li Ming <ming.li@zohomail.com>,
dave@stgolabs.net, dave.jiang@intel.com,
alison.schofield@intel.com, vishal.l.verma@intel.com,
ira.weiny@intel.com, dan.j.williams@intel.com,
linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] cxl/core: Set cxlmd->endpoint to NULL by default
Date: Mon, 2 Feb 2026 10:48:14 -0500 [thread overview]
Message-ID: <aYDHPhun61wkw7Fi@gourry-fedora-PF4VCD3F> (raw)
In-Reply-To: <20260202144103.000016cb@huawei.com>
On Mon, Feb 02, 2026 at 02:41:03PM +0000, Jonathan Cameron wrote:
> On Sun, 1 Feb 2026 17:30:01 +0800
> Li Ming <ming.li@zohomail.com> wrote:
>
> > CXL testing environment can trigger following trace
> >
> > Oops: general protection fault, probably for non-canonical address 0xdffffc0000000092: 0000 [#1] SMP KASAN NOPTI
> > KASAN: null-ptr-deref in range [0x0000000000000490-0x0000000000000497]
> > RIP: 0010:cxl_dpa_to_region+0x105/0x1f0 [cxl_core]
> > Call Trace:
> > <TASK>
> > cxl_event_trace_record+0xd1/0xa70 [cxl_core]
> > __cxl_event_trace_record+0x12f/0x1e0 [cxl_core]
> > cxl_mem_get_records_log+0x261/0x500 [cxl_core]
> > cxl_mem_get_event_records+0x7c/0xc0 [cxl_core]
> > cxl_mock_mem_probe+0xd38/0x1c60 [cxl_mock_mem]
> > platform_probe+0x9d/0x130
> > really_probe+0x1c8/0x960
> > __driver_probe_device+0x187/0x3e0
> > driver_probe_device+0x45/0x120
> > __device_attach_driver+0x15d/0x280
> >
> > commit 29317f8dc6ed ("cxl/mem: Introduce cxl_memdev_attach for CXL-dependent operation")
> > initializes cxlmd->endpoint to ERR_PTR(-ENXIO) in cxl_memdev_alloc().
> > However, cxl_dpa_to_region() treats a non-NULL cxlmd->endpoint as a
> > valid endpoint.
> >
> > Across the CXL core, endpoint availability is generally determined by
> > checking whether it is NULL. Align with this convention by initializing
> > cxlmd->endpoint to NULL by default.
>
> I had a look at whether it made sense to use use IS_ERR_OR_NULL() to check
> for validity of the endpoint, but it would be somewhat fiddly and I think
> you are correct that convention here seems to be NULL means not set.
> We don't need the error code. One comment inline.
>
doing validity checks on pointers by checking for null is a pretty
common convention kernel-wide, I would consider setting some structure's
value to an ERR_PTR to be the aberration.
So yeah, good catch
Reviewed-by: Gregory Price <gourry@gourry.net>
~Gregory
next prev parent reply other threads:[~2026-02-02 15:48 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-01 9:30 [PATCH 0/2] Fix port enumeration failure and NULL endpoint issue Li Ming
2026-02-01 9:30 ` [PATCH 1/2] cxl/core: Set cxlmd->endpoint to NULL by default Li Ming
2026-02-02 14:41 ` Jonathan Cameron
2026-02-02 15:48 ` Gregory Price [this message]
2026-02-03 14:15 ` Li Ming
2026-02-02 21:04 ` Dave Jiang
2026-02-03 15:04 ` Li Ming
2026-02-03 0:01 ` dan.j.williams
2026-02-03 15:15 ` Li Ming
2026-02-03 22:37 ` dan.j.williams
2026-02-01 9:30 ` [PATCH 2/2] cxl/core: Hold grandparent port lock while dport adding Li Ming
2026-02-02 15:39 ` Jonathan Cameron
2026-02-03 14:23 ` Li Ming
2026-02-03 21:14 ` dan.j.williams
2026-02-02 16:31 ` Gregory Price
2026-02-03 14:33 ` Li Ming
2026-02-03 0:07 ` dan.j.williams
2026-02-03 15:21 ` Li Ming
2026-02-03 22:25 ` dan.j.williams
2026-02-04 13:51 ` Li Ming
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=aYDHPhun61wkw7Fi@gourry-fedora-PF4VCD3F \
--to=gourry@gourry.net \
--cc=alison.schofield@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=ira.weiny@intel.com \
--cc=jonathan.cameron@huawei.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.li@zohomail.com \
--cc=vishal.l.verma@intel.com \
/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