Skip to content

Commit 47c370c

Browse files
sudipm-mukherjeejgunthorpe
authored andcommitted
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: ff23dfa ("IB: Pass only ib_udata in function prototypes") Link: https://lore.kernel.org/r/[email protected] Cc: [email protected] [5.4+] Tested-by: Mike Marciniszyn <[email protected]> Acked-by: Mike Marciniszyn <[email protected]> Signed-off-by: Sudip Mukherjee <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 83a2670 commit 47c370c

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

drivers/infiniband/sw/rdmavt/cq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ int rvt_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
248248
*/
249249
if (udata && udata->outlen >= sizeof(__u64)) {
250250
cq->ip = rvt_create_mmap_info(rdi, sz, udata, u_wc);
251-
if (!cq->ip) {
252-
err = -ENOMEM;
251+
if (IS_ERR(cq->ip)) {
252+
err = PTR_ERR(cq->ip);
253253
goto bail_wc;
254254
}
255255

drivers/infiniband/sw/rdmavt/mmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ int rvt_mmap(struct ib_ucontext *context, struct vm_area_struct *vma)
154154
* @udata: user data (must be valid!)
155155
* @obj: opaque pointer to a cq, wq etc
156156
*
157-
* Return: rvt_mmap struct on success
157+
* Return: rvt_mmap struct on success, ERR_PTR on failure
158158
*/
159159
struct rvt_mmap_info *rvt_create_mmap_info(struct rvt_dev_info *rdi, u32 size,
160160
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,
166166

167167
ip = kmalloc_node(sizeof(*ip), GFP_KERNEL, rdi->dparms.node);
168168
if (!ip)
169-
return ip;
169+
return ERR_PTR(-ENOMEM);
170170

171171
size = PAGE_ALIGN(size);
172172

drivers/infiniband/sw/rdmavt/qp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,8 +1244,8 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd,
12441244

12451245
qp->ip = rvt_create_mmap_info(rdi, s, udata,
12461246
qp->r_rq.wq);
1247-
if (!qp->ip) {
1248-
ret = ERR_PTR(-ENOMEM);
1247+
if (IS_ERR(qp->ip)) {
1248+
ret = ERR_CAST(qp->ip);
12491249
goto bail_qpn;
12501250
}
12511251

drivers/infiniband/sw/rdmavt/srq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ int rvt_create_srq(struct ib_srq *ibsrq, struct ib_srq_init_attr *srq_init_attr,
111111
u32 s = sizeof(struct rvt_rwq) + srq->rq.size * sz;
112112

113113
srq->ip = rvt_create_mmap_info(dev, s, udata, srq->rq.wq);
114-
if (!srq->ip) {
115-
ret = -ENOMEM;
114+
if (IS_ERR(srq->ip)) {
115+
ret = PTR_ERR(srq->ip);
116116
goto bail_wq;
117117
}
118118

0 commit comments

Comments
 (0)