Skip to contentSkip to conversation

cxl/features: Add check for no entries in cxl_feature_info

PATCH Applied Dave Jiang 3 participants 4 messages Oct 9, 2025 – Oct 14, 2025 CXL

lore
Share & tools
lore

Dave Jiang

author maintainer
#0 lore raw

PATCH 1/1 cxl/features: Add check for no entries in cxl_feature_info

cxl EDAC calls cxl_feature_info() to get the feature information and if the hardware has no Features support, cxlfs may be passed in as NULL.

[   51.957498] BUG: kernel NULL pointer dereference, address: 0000000000000008
[   51.965571] #PF: supervisor read access in kernel mode
[   51.971559] #PF: error_code(0x0000) - not-present page
[   51.977542] PGD 17e4f6067 P4D 0
[   51.981384] Oops: Oops: 0000 [#1] SMP NOPTI
[   51.986300] CPU: 49 UID: 0 PID: 3782 Comm: systemd-udevd Not tainted 6.17.0dj
test+ #64 PREEMPT(voluntary)
[   51.997355] Hardware name: <removed>
[   52.009790] RIP: 0010:cxl_feature_info+0xa/0x80 [cxl_core]

Add a check for cxlfs before dereferencing it and return -EOPNOTSUPP if there is no cxlfs created due to no hardware support.

Fixes eb5dfcb9e36d ("cxl: Add support to handle user feature commands for set feature")
---
 drivers/cxl/core/features.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/cxl/core/features.c +3 -0
index 7c750599ea69..4bc484b46f43 100644
@@ -371,6 +371,9 @@ cxl_feature_info(struct cxl_features_state *cxlfs,
 {
 	struct cxl_feat_entry *feat;
 
+	if (!cxlfs || !cxlfs->entries)
+		return ERR_PTR(-EOPNOTSUPP);
+
 	for (int i = 0; i < cxlfs->entries->num_features; i++) {
 		feat = &cxlfs->entries->ent[i];
 		if (uuid_equal(uuid, &feat->uuid))

base-commit: e5f0a698b34ed76002dc5cff3804a61c80233a7a
prerequisite-patch-id: e3c6c0e3b81959629a6ffecd3994f683d0d530e4

Signature · 1 line
2.51.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Dave Jiang

cxl EDAC calls cxl_feature_info() to get the feature information and if the hardware has no Features support, cxlfs may be passed in as NULL.

[   51.957498] BUG: kernel NULL pointer dereference, address: 0000000000000008
[   51.965571] #PF: supervisor read access in kernel mode
[   51.971559] #PF: error_code(0x0000) - not-present page
[   51.977542] PGD 17e4f6067 P4D 0
[   51.981384] Oops: Oops: 0000 [#1] SMP NOPTI
[   51.986300] CPU: 49 UID: 0 PID: 3782 Comm: systemd-udevd Not tainted 6.17.0dj
test+ #64 PREEMPT(voluntary)
[   51.997355] Hardware name: <removed>
[   52.009790] RIP: 0010:cxl_feature_info+0xa/0x80 [cxl_core]
Quoted 2 lines

Add a check for cxlfs before dereferencing it and return -EOPNOTSUPP if there is no cxlfs created due to no hardware support.

Quoted 27 lines
Fixes eb5dfcb9e36d ("cxl: Add support to handle user feature commands for set feature")
---
 drivers/cxl/core/features.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/cxl/core/features.c +3 -0
index 7c750599ea69..4bc484b46f43 100644
@@ -371,6 +371,9 @@ cxl_feature_info(struct cxl_features_state *cxlfs,
 {
 	struct cxl_feat_entry *feat;
 
+	if (!cxlfs || !cxlfs->entries)
+		return ERR_PTR(-EOPNOTSUPP);
+
 	for (int i = 0; i < cxlfs->entries->num_features; i++) {
 		feat = &cxlfs->entries->ent[i];
 		if (uuid_equal(uuid, &feat->uuid))

base-commit: e5f0a698b34ed76002dc5cff3804a61c80233a7a
prerequisite-patch-id: e3c6c0e3b81959629a6ffecd3994f683d0d530e4

Signature · 1 line
2.51.0
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Dave Jiang
Quoted 14 lines · Dave Jiang

cxl EDAC calls cxl_feature_info() to get the feature information and if the hardware has no Features support, cxlfs may be passed in as NULL.

[   51.957498] BUG: kernel NULL pointer dereference, address: 0000000000000008
[   51.965571] #PF: supervisor read access in kernel mode
[   51.971559] #PF: error_code(0x0000) - not-present page
[   51.977542] PGD 17e4f6067 P4D 0
[   51.981384] Oops: Oops: 0000 [#1] SMP NOPTI
[   51.986300] CPU: 49 UID: 0 PID: 3782 Comm: systemd-udevd Not tainted 6.17.0dj
test+ #64 PREEMPT(voluntary)
[   51.997355] Hardware name: <removed>
[   52.009790] RIP: 0010:cxl_feature_info+0xa/0x80 [cxl_core]
Quoted 5 lines

Add a check for cxlfs before dereferencing it and return -EOPNOTSUPP if there is no cxlfs created due to no hardware support.

Fixes eb5dfcb9e36d ("cxl: Add support to handle user feature commands for set feature")

lgtm

author maintainer Applied
#3 lore raw
In reply to Dave Jiang
Quoted 14 lines · Dave Jiang

cxl EDAC calls cxl_feature_info() to get the feature information and if the hardware has no Features support, cxlfs may be passed in as NULL.

[   51.957498] BUG: kernel NULL pointer dereference, address: 0000000000000008
[   51.965571] #PF: supervisor read access in kernel mode
[   51.971559] #PF: error_code(0x0000) - not-present page
[   51.977542] PGD 17e4f6067 P4D 0
[   51.981384] Oops: Oops: 0000 [#1] SMP NOPTI
[   51.986300] CPU: 49 UID: 0 PID: 3782 Comm: systemd-udevd Not tainted 6.17.0dj
test+ #64 PREEMPT(voluntary)
[   51.997355] Hardware name: <removed>
[   52.009790] RIP: 0010:cxl_feature_info+0xa/0x80 [cxl_core]
Quoted 5 lines

Add a check for cxlfs before dereferencing it and return -EOPNOTSUPP if there is no cxlfs created due to no hardware support.

Fixes eb5dfcb9e36d ("cxl: Add support to handle user feature commands for set feature")

Applied to cxl/fixes

Quoted 21 lines
---
 drivers/cxl/core/features.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/cxl/core/features.c +3 -0
index 7c750599ea69..4bc484b46f43 100644
@@ -371,6 +371,9 @@ cxl_feature_info(struct cxl_features_state *cxlfs,
 {
 	struct cxl_feat_entry *feat;
 
+	if (!cxlfs || !cxlfs->entries)
+		return ERR_PTR(-EOPNOTSUPP);
+
 	for (int i = 0; i < cxlfs->entries->num_features; i++) {
 		feat = &cxlfs->entries->ent[i];
 		if (uuid_equal(uuid, &feat->uuid))

base-commit: e5f0a698b34ed76002dc5cff3804a61c80233a7a
prerequisite-patch-id: e3c6c0e3b81959629a6ffecd3994f683d0d530e4