Commit 47c370c1 authored by Sudip Mukherjee's avatar Sudip Mukherjee Committed by Jason Gunthorpe

IB/rdmavt: Always return ERR_PTR from rvt_create_mmap_info()

The commit below modified rvt_create_mmap_info() to return ERR_PTR's but
didn't update the callers to handle them. Modify rvt_create_mmap_info() to
only return ERR_PTR and fix all error checking after
rvt_create_mmap_info() was called.

Fixes: ff23dfa1 ("IB: Pass only ib_udata in function prototypes")
Link: https://lore.kernel.org/r/20200424173146.10970-1-sudipm.mukherjee@gmail.com
Cc: stable@vger.kernel.org [5.4+]
Tested-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
Acked-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 83a26702
...@@ -248,8 +248,8 @@ int rvt_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, ...@@ -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)) { if (udata && udata->outlen >= sizeof(__u64)) {
cq->ip = rvt_create_mmap_info(rdi, sz, udata, u_wc); cq->ip = rvt_create_mmap_info(rdi, sz, udata, u_wc);
if (!cq->ip) { if (IS_ERR(cq->ip)) {
err = -ENOMEM; err = PTR_ERR(cq->ip);
goto bail_wc; goto bail_wc;
} }
......
...@@ -154,7 +154,7 @@ int rvt_mmap(struct ib_ucontext *context, struct vm_area_struct *vma) ...@@ -154,7 +154,7 @@ int rvt_mmap(struct ib_ucontext *context, struct vm_area_struct *vma)
* @udata: user data (must be valid!) * @udata: user data (must be valid!)
* @obj: opaque pointer to a cq, wq etc * @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 rvt_mmap_info *rvt_create_mmap_info(struct rvt_dev_info *rdi, u32 size,
struct ib_udata *udata, void *obj) 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, ...@@ -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); ip = kmalloc_node(sizeof(*ip), GFP_KERNEL, rdi->dparms.node);
if (!ip) if (!ip)
return ip; return ERR_PTR(-ENOMEM);
size = PAGE_ALIGN(size); size = PAGE_ALIGN(size);
......
...@@ -1244,8 +1244,8 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd, ...@@ -1244,8 +1244,8 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd,
qp->ip = rvt_create_mmap_info(rdi, s, udata, qp->ip = rvt_create_mmap_info(rdi, s, udata,
qp->r_rq.wq); qp->r_rq.wq);
if (!qp->ip) { if (IS_ERR(qp->ip)) {
ret = ERR_PTR(-ENOMEM); ret = ERR_CAST(qp->ip);
goto bail_qpn; goto bail_qpn;
} }
......
...@@ -111,8 +111,8 @@ int rvt_create_srq(struct ib_srq *ibsrq, struct ib_srq_init_attr *srq_init_attr, ...@@ -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; u32 s = sizeof(struct rvt_rwq) + srq->rq.size * sz;
srq->ip = rvt_create_mmap_info(dev, s, udata, srq->rq.wq); srq->ip = rvt_create_mmap_info(dev, s, udata, srq->rq.wq);
if (!srq->ip) { if (IS_ERR(srq->ip)) {
ret = -ENOMEM; ret = PTR_ERR(srq->ip);
goto bail_wq; goto bail_wq;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment