diff mbox series

[v3] IB/rdmavt: return proper error code

Message ID 20200424173146.10970-1-sudipm.mukherjee@gmail.com (mailing list archive)
State Mainlined
Commit 47c370c1a5eea9b2f6f026d49e060c3748c89667
Delegated to: Jason Gunthorpe
Headers show
Series [v3] IB/rdmavt: return proper error code | expand

Commit Message

Sudip Mukherjee April 24, 2020, 5:31 p.m. UTC
The commit 'ff23dfa13457' modified rvt_create_mmap_info() to return
error code and also NULL but missed fixing codes which called
rvt_create_mmap_info(). Modify rvt_create_mmap_info() to only return
errorcode and fix error checking after rvt_create_mmap_info() was
called.

Fixes: ff23dfa13457 ("IB: Pass only ib_udata in function prototypes")
Cc: stable@vger.kernel.org [5.4+]
Tested-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Acked-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
---
 drivers/infiniband/sw/rdmavt/cq.c   | 4 ++--
 drivers/infiniband/sw/rdmavt/mmap.c | 4 ++--
 drivers/infiniband/sw/rdmavt/qp.c   | 4 ++--
 drivers/infiniband/sw/rdmavt/srq.c  | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

Comments

Jason Gunthorpe April 24, 2020, 6:33 p.m. UTC | #1
On Fri, Apr 24, 2020 at 06:31:46PM +0100, Sudip Mukherjee wrote:
> The commit 'ff23dfa13457' modified rvt_create_mmap_info() to return
> error code and also NULL but missed fixing codes which called
> rvt_create_mmap_info(). Modify rvt_create_mmap_info() to only return
> errorcode and fix error checking after rvt_create_mmap_info() was
> called.
> 
> Fixes: ff23dfa13457 ("IB: Pass only ib_udata in function prototypes")
> Cc: stable@vger.kernel.org [5.4+]
> Tested-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
> Acked-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
> Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
> ---
>  drivers/infiniband/sw/rdmavt/cq.c   | 4 ++--
>  drivers/infiniband/sw/rdmavt/mmap.c | 4 ++--
>  drivers/infiniband/sw/rdmavt/qp.c   | 4 ++--
>  drivers/infiniband/sw/rdmavt/srq.c  | 4 ++--
>  4 files changed, 8 insertions(+), 8 deletions(-)

Applied to for-next, thanks

Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/sw/rdmavt/cq.c b/drivers/infiniband/sw/rdmavt/cq.c
index 5724cbbe38b1..04d2e72017fe 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(cq->ip)) {
+			err = PTR_ERR(cq->ip);
 			goto bail_wc;
 		}
 
diff --git a/drivers/infiniband/sw/rdmavt/mmap.c b/drivers/infiniband/sw/rdmavt/mmap.c
index 652f4a7efc1b..37853aa3bcf7 100644
--- a/drivers/infiniband/sw/rdmavt/mmap.c
+++ b/drivers/infiniband/sw/rdmavt/mmap.c
@@ -154,7 +154,7 @@  int rvt_mmap(struct ib_ucontext *context, struct vm_area_struct *vma)
  * @udata: user data (must be valid!)
  * @obj: opaque pointer to a cq, wq etc
  *
- * Return: rvt_mmap struct on success
+ * Return: rvt_mmap struct on success, ERR_PTR on failure
  */
 struct rvt_mmap_info *rvt_create_mmap_info(struct rvt_dev_info *rdi, u32 size,
 					   struct ib_udata *udata, void *obj)
@@ -166,7 +166,7 @@  struct rvt_mmap_info *rvt_create_mmap_info(struct rvt_dev_info *rdi, u32 size,
 
 	ip = kmalloc_node(sizeof(*ip), GFP_KERNEL, rdi->dparms.node);
 	if (!ip)
-		return ip;
+		return ERR_PTR(-ENOMEM);
 
 	size = PAGE_ALIGN(size);
 
diff --git a/drivers/infiniband/sw/rdmavt/qp.c b/drivers/infiniband/sw/rdmavt/qp.c
index 0e1b291d2cec..500a7ee04c44 100644
--- a/drivers/infiniband/sw/rdmavt/qp.c
+++ b/drivers/infiniband/sw/rdmavt/qp.c
@@ -1244,8 +1244,8 @@  struct ib_qp *rvt_create_qp(struct ib_pd *ibpd,
 
 			qp->ip = rvt_create_mmap_info(rdi, s, udata,
 						      qp->r_rq.wq);
-			if (!qp->ip) {
-				ret = ERR_PTR(-ENOMEM);
+			if (IS_ERR(qp->ip)) {
+				ret = ERR_CAST(qp->ip);
 				goto bail_qpn;
 			}
 
diff --git a/drivers/infiniband/sw/rdmavt/srq.c b/drivers/infiniband/sw/rdmavt/srq.c
index 24fef021d51d..f547c115af03 100644
--- a/drivers/infiniband/sw/rdmavt/srq.c
+++ b/drivers/infiniband/sw/rdmavt/srq.c
@@ -111,8 +111,8 @@  int rvt_create_srq(struct ib_srq *ibsrq, struct ib_srq_init_attr *srq_init_attr,
 		u32 s = sizeof(struct rvt_rwq) + srq->rq.size * sz;
 
 		srq->ip = rvt_create_mmap_info(dev, s, udata, srq->rq.wq);
-		if (!srq->ip) {
-			ret = -ENOMEM;
+		if (IS_ERR(srq->ip)) {
+			ret = PTR_ERR(srq->ip);
 			goto bail_wq;
 		}