Skip to contentSkip to conversation

cxl: fix return value in cxlctl_validate_set_features()

PATCH Applied Dan Carpenter 5 participants 6 messages May 28, 2025 – Jun 9, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cxl: fix return value in cxlctl_validate_set_features()

The cxlctl_validate_set_features() function is type bool. It's supposed to return true for valid requests and false for invalid. However, this error path returns ERR_PTR(-EINVAL) which is true when it was intended to return false.

Fixes f76e0bbc8bc3 ("cxl: Update prototype of function get_support_feature_info()")
---
 drivers/cxl/core/features.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cxl/core/features.c +1 -1
index 6f2eae1eb126..7c750599ea69 100644
@@ -544,7 +544,7 @@ static bool cxlctl_validate_set_features(struct cxl_features_state *cxlfs,
 	u32 flags;
 
 	if (rpc_in->op_size < sizeof(uuid_t))
-		return ERR_PTR(-EINVAL);
+		return false;
 
 	feat = cxl_feature_info(cxlfs, &rpc_in->set_feat_in.uuid);
 	if (IS_ERR(feat))
Signature · 1 line
2.47.2
maintainer
#1 lore raw
Quoted 4 lines · Dan Carpenter

The cxlctl_validate_set_features() function is type bool. It's supposed to return true for valid requests and false for invalid. However, this error path returns ERR_PTR(-EINVAL) which is true when it was intended to return false.

Shiju - Can you trace this one through and add the impact statement? Wondering if this is going to fail gracefully, or badly, further down this path?

Quoted 23 lines
Fixes f76e0bbc8bc3 ("cxl: Update prototype of function get_support_feature_info()")
---
 drivers/cxl/core/features.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cxl/core/features.c +1 -1
index 6f2eae1eb126..7c750599ea69 100644
@@ -544,7 +544,7 @@ static bool cxlctl_validate_set_features(struct cxl_features_state *cxlfs,
 	u32 flags;
 
 	if (rpc_in->op_size < sizeof(uuid_t))
-		return ERR_PTR(-EINVAL);
+		return false;
 
 	feat = cxl_feature_info(cxlfs, &rpc_in->set_feat_in.uuid);
 	if (IS_ERR(feat))
Signature · 1 line
2.47.2
#2 lore raw
Quoted 10 lines · Alison Schofield
Quoted 4 lines · Dan Carpenter

The cxlctl_validate_set_features() function is type bool. It's supposed to return true for valid requests and false for invalid. However, this error path returns ERR_PTR(-EINVAL) which is true when it was intended to return false.

Shiju - Can you trace this one through and add the impact statement? Wondering if this is going to fail gracefully, or badly, further down this path?

Sorry, I would normally analyse this a bit more myself, but it's only in linux-next so I assumed no one was using it yet. It ends up being fine.

cxlctl_set_feature() has a check for:

	if (rpc_in->op_size <= sizeof(feat_in->hdr))

at the start and sizeof(feat_in->hdr) is larger than sizeof(uuid_t).

regards,
dan carpenter

#3 lore raw
In reply to Alison Schofield
Quoted 13 lines

-----Original Message-----
From: Alison Schofield <[email protected]>
Sent: 28 May 2025 16:23
To: Shiju Jose <[email protected]>; Dan Carpenter <[email protected]>
Cc: Davidlohr Bueso <[email protected]>; Jonathan Cameron <[email protected]>; Dave Jiang <[email protected]>; Vishal Verma <[email protected]>; Ira Weiny <[email protected]>; Dan Williams <[email protected]>; Li Ming <[email protected]>; Fan Ni <[email protected]>; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [PATCH next] cxl: fix return value in cxlctl_validate_set_features()

Quoted 8 lines
Quoted 4 lines · Dan Carpenter

The cxlctl_validate_set_features() function is type bool. It's supposed to return true for valid requests and false for invalid. However, this error path returns ERR_PTR(-EINVAL) which is true when it was intended to return false.

Shiju - Can you trace this one through and add the impact statement? Wondering if this is going to fail gracefully, or badly, further down this path?

Hi Alison,

This is introduced when following fwctl specific code move out of common function (use both in fwctl and edac path) get_support_feature_info() to fwctl specific function cxlctl_validae_set_feature().
"if (rpc_in->op_size < sizeof(uuid_t))
return ERR_PTR(-EINVAL);"

This may have an impact on fwctl side if the above check pass.

Thanks,
Shiju

Quoted 26 lines

drivers/cxl/core/features.c static bool cxlctl_validate_set_features(struct

Quoted 14 lines
Fixes f76e0bbc8bc3 ("cxl: Update prototype of function

get_support_feature_info()")

---
 drivers/cxl/core/features.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cxl/core/features.c +0 -0
index 6f2eae1eb126..7c750599ea69 100644
@@ -544,7 +544,7 @@ static bool cxlctl_validate_set_features(struct

cxl_features_state *cxlfs,

Quoted 11 lines
drivers/cxl/core/features.c +1 -2
 	u32 flags;
 
 	if (rpc_in->op_size < sizeof(uuid_t))
-		return ERR_PTR(-EINVAL);
+		return false;
 
 	feat = cxl_feature_info(cxlfs, &rpc_in->set_feat_in.uuid);
 	if (IS_ERR(feat))
--

2.47.2

Reviewed-by
#4 lore raw
Quoted 24 lines · Shiju Jose
Quoted 13 lines

-----Original Message-----
From: Alison Schofield <[email protected]>
Sent: 28 May 2025 16:23
To: Shiju Jose <[email protected]>; Dan Carpenter <[email protected]>
Cc: Davidlohr Bueso <[email protected]>; Jonathan Cameron <[email protected]>; Dave Jiang <[email protected]>; Vishal Verma <[email protected]>; Ira Weiny <[email protected]>; Dan Williams <[email protected]>; Li Ming <[email protected]>; Fan Ni <[email protected]>; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [PATCH next] cxl: fix return value in cxlctl_validate_set_features()

Quoted 8 lines
Quoted 4 lines · Dan Carpenter

The cxlctl_validate_set_features() function is type bool. It's supposed to return true for valid requests and false for invalid. However, this error path returns ERR_PTR(-EINVAL) which is true when it was intended to return false.

Shiju - Can you trace this one through and add the impact statement? Wondering if this is going to fail gracefully, or badly, further down this path?

Hi Alison,

Quoted 9 lines

This is introduced when following fwctl specific code move out of common function (use both in fwctl and edac path) get_support_feature_info() to fwctl specific function cxlctl_validae_set_feature().
"if (rpc_in->op_size < sizeof(uuid_t))
return ERR_PTR(-EINVAL);"

This may have an impact on fwctl side if the above check pass.

I got a bit sidetracked by this conversation.

It seems the TLDR is:

This fix is not required. But should be fixed for long term correctness.

With that interpretation.

maintainer Applied
#5 lore raw
In reply to Dan Carpenter
Quoted 7 lines · Dan Carpenter

The cxlctl_validate_set_features() function is type bool. It's supposed to return true for valid requests and false for invalid. However, this error path returns ERR_PTR(-EINVAL) which is true when it was intended to return false.

Fixes f76e0bbc8bc3 ("cxl: Update prototype of function get_support_feature_info()")

Applied to cxl/fixes

Quoted 17 lines
---
 drivers/cxl/core/features.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cxl/core/features.c +1 -1
index 6f2eae1eb126..7c750599ea69 100644
@@ -544,7 +544,7 @@ static bool cxlctl_validate_set_features(struct cxl_features_state *cxlfs,
 	u32 flags;
 
 	if (rpc_in->op_size < sizeof(uuid_t))
-		return ERR_PTR(-EINVAL);
+		return false;
 
 	feat = cxl_feature_info(cxlfs, &rpc_in->set_feat_in.uuid);
 	if (IS_ERR(feat))