[PATCH] IB/rdmavt: return proper error code

From: Sudip Mukherjee
Date: Thu Apr 23 2020 - 08:04:49 EST


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@xxxxxxxxx>
---
drivers/infiniband/sw/rdmavt/cq.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

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;
}

--
2.11.0