diff mbox series

IB/rdmavt: return proper error code

Message ID 20200423120434.19304-1-sudipm.mukherjee@gmail.com (mailing list archive)
State Superseded
Headers show
Series IB/rdmavt: return proper error code | expand

Commit Message

Sudip Mukherjee April 23, 2020, 12:04 p.m. UTC
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.

Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
---
 drivers/infiniband/sw/rdmavt/cq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jason Gunthorpe April 23, 2020, 2:09 p.m. UTC | #1
On Thu, Apr 23, 2020 at 01:04:34PM +0100, Sudip Mukherjee wrote:
> 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
Dennis Dalessandro April 24, 2020, 12:27 p.m. UTC | #2
On 4/23/2020 10:09 AM, Jason Gunthorpe wrote:
> On Thu, Apr 23, 2020 at 01:04:34PM +0100, Sudip Mukherjee wrote:
>> 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
Marciniszyn, Mike April 24, 2020, 1:50 p.m. UTC | #3
> Subject: Re: [PATCH] IB/rdmavt: return proper error code
> 
> On Thu, Apr 23, 2020 at 01:04:34PM +0100, Sudip Mukherjee wrote:
> > 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

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
Jason Gunthorpe April 24, 2020, 2 p.m. UTC | #4
On Fri, Apr 24, 2020 at 01:50:22PM +0000, Marciniszyn, Mike wrote:
> > Subject: Re: [PATCH] IB/rdmavt: return proper error code
> > 
> > On Thu, Apr 23, 2020 at 01:04:34PM +0100, Sudip Mukherjee wrote:
> > > 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
> 
> 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
diff mbox series

Patch

diff --git a/drivers/infiniband/sw/rdmavt/cq.c b/drivers/infiniband/sw/rdmavt/cq.c
index 5724cbbe38b1..326b1e6b362d 100644
--- a/drivers/infiniband/sw/rdmavt/cq.c
+++ b/drivers/infiniband/sw/rdmavt/cq.c
@@ -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;
 		}