Skip to contentSkip to conversation

IB/rdmavt: return proper error code

PATCH Superseded Sudip Mukherjee 4 participants 5 messages Apr 23, 2020 – Apr 24, 2020

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IB/rdmavt: return proper error code

The function rvt_create_mmap_info() can return either NULL or an error in ERR_PTR(). Check properly for both the error type and return the error code accordingly.

---
 drivers/infiniband/sw/rdmavt/cq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/sw/rdmavt/cq.c +2 -2
index 5724cbbe38b1..326b1e6b362d 100644
@@ -248,8 +248,8 @@ int rvt_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
 	 */
 	if (udata && udata->outlen >= sizeof(__u64)) {
 		cq->ip = rvt_create_mmap_info(rdi, sz, udata, u_wc);
-		if (!cq->ip) {
-			err = -ENOMEM;
+		if (IS_ERR_OR_NULL(cq->ip)) {
+			err = cq->ip ? PTR_ERR(cq->ip) : -ENOMEM;
 			goto bail_wc;
 		}
 
Signature · 1 line
2.11.0
#1 lore raw
Quoted 3 lines · Sudip Mukherjee

The function rvt_create_mmap_info() can return either NULL or an error in ERR_PTR(). Check properly for both the error type and return the error code accordingly.

Please fix rvt_create_mmap_info to always return ERR_PTR, never null on failure.

Thanks,
Jason

#2 lore raw
Quoted 11 lines · Jason Gunthorpe
Quoted 3 lines · Sudip Mukherjee

The function rvt_create_mmap_info() can return either NULL or an error in ERR_PTR(). Check properly for both the error type and return the error code accordingly.

Please fix rvt_create_mmap_info to always return ERR_PTR, never null on failure.

Thanks,
Jason

Yes, that is a better approach.

-Denny

#3 lore raw
In reply to Jason Gunthorpe
Quoted 7 lines

Subject: Re: [PATCH] IB/rdmavt: return proper error code

Quoted 3 lines · Sudip Mukherjee

The function rvt_create_mmap_info() can return either NULL or an error in ERR_PTR(). Check properly for both the error type and return the error code accordingly.

Quoted 5 lines

Please fix rvt_create_mmap_info to always return ERR_PTR, never null on failure.

Thanks,
Jason

I agree on the ERR_PTR return, but the patch is incomplete.

The original patch:

Fixes ff23dfa13457 ("IB: Pass only ib_udata in function prototypes")

Broke all the call sites: cq.c, srq.c, and qp.c.

Mike

#4 lore raw
Quoted 13 lines · Mike
Quoted 7 lines

Subject: Re: [PATCH] IB/rdmavt: return proper error code

Quoted 3 lines · Sudip Mukherjee

The function rvt_create_mmap_info() can return either NULL or an error in ERR_PTR(). Check properly for both the error type and return the error code accordingly.

Quoted 5 lines

Please fix rvt_create_mmap_info to always return ERR_PTR, never null on failure.

Thanks,
Jason

Quoted 7 lines

I agree on the ERR_PTR return, but the patch is incomplete.

The original patch:

Fixes ff23dfa13457 ("IB: Pass only ib_udata in function prototypes")

Broke all the call sites: cq.c, srq.c, and qp.c.

Sure looks like it, someone make a patch..

Jason