diff options
| -rw-r--r-- | drivers/infiniband/core/uverbs_cmd.c | 66 |
1 files changed, 35 insertions, 31 deletions
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 85231e2bdeef..ad750f3c6ca0 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c | |||
| @@ -1423,13 +1423,6 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file, | |||
| 1423 | } | 1423 | } |
| 1424 | device = xrcd->device; | 1424 | device = xrcd->device; |
| 1425 | } else { | 1425 | } else { |
| 1426 | pd = idr_read_pd(cmd.pd_handle, file->ucontext); | ||
| 1427 | scq = idr_read_cq(cmd.send_cq_handle, file->ucontext, 0); | ||
| 1428 | if (!pd || !scq) { | ||
| 1429 | ret = -EINVAL; | ||
| 1430 | goto err_put; | ||
| 1431 | } | ||
| 1432 | |||
| 1433 | if (cmd.qp_type == IB_QPT_XRC_INI) { | 1426 | if (cmd.qp_type == IB_QPT_XRC_INI) { |
| 1434 | cmd.max_recv_wr = cmd.max_recv_sge = 0; | 1427 | cmd.max_recv_wr = cmd.max_recv_sge = 0; |
| 1435 | } else { | 1428 | } else { |
| @@ -1440,13 +1433,24 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file, | |||
| 1440 | goto err_put; | 1433 | goto err_put; |
| 1441 | } | 1434 | } |
| 1442 | } | 1435 | } |
| 1443 | rcq = (cmd.recv_cq_handle == cmd.send_cq_handle) ? | 1436 | |
| 1444 | scq : idr_read_cq(cmd.recv_cq_handle, file->ucontext, 1); | 1437 | if (cmd.recv_cq_handle != cmd.send_cq_handle) { |
| 1445 | if (!rcq) { | 1438 | rcq = idr_read_cq(cmd.recv_cq_handle, file->ucontext, 0); |
| 1446 | ret = -EINVAL; | 1439 | if (!rcq) { |
| 1447 | goto err_put; | 1440 | ret = -EINVAL; |
| 1441 | goto err_put; | ||
| 1442 | } | ||
| 1448 | } | 1443 | } |
| 1449 | } | 1444 | } |
| 1445 | |||
| 1446 | scq = idr_read_cq(cmd.send_cq_handle, file->ucontext, !!rcq); | ||
| 1447 | rcq = rcq ?: scq; | ||
| 1448 | pd = idr_read_pd(cmd.pd_handle, file->ucontext); | ||
| 1449 | if (!pd || !scq) { | ||
| 1450 | ret = -EINVAL; | ||
| 1451 | goto err_put; | ||
| 1452 | } | ||
| 1453 | |||
| 1450 | device = pd->device; | 1454 | device = pd->device; |
| 1451 | } | 1455 | } |
| 1452 | 1456 | ||
| @@ -2484,27 +2488,27 @@ static int __uverbs_create_xsrq(struct ib_uverbs_file *file, | |||
| 2484 | init_uobj(&obj->uevent.uobject, cmd->user_handle, file->ucontext, &srq_lock_class); | 2488 | init_uobj(&obj->uevent.uobject, cmd->user_handle, file->ucontext, &srq_lock_class); |
| 2485 | down_write(&obj->uevent.uobject.mutex); | 2489 | down_write(&obj->uevent.uobject.mutex); |
| 2486 | 2490 | ||
| 2487 | pd = idr_read_pd(cmd->pd_handle, file->ucontext); | ||
| 2488 | if (!pd) { | ||
| 2489 | ret = -EINVAL; | ||
| 2490 | goto err; | ||
| 2491 | } | ||
| 2492 | |||
| 2493 | if (cmd->srq_type == IB_SRQT_XRC) { | 2491 | if (cmd->srq_type == IB_SRQT_XRC) { |
| 2494 | attr.ext.xrc.cq = idr_read_cq(cmd->cq_handle, file->ucontext, 0); | ||
| 2495 | if (!attr.ext.xrc.cq) { | ||
| 2496 | ret = -EINVAL; | ||
| 2497 | goto err_put_pd; | ||
| 2498 | } | ||
| 2499 | |||
| 2500 | attr.ext.xrc.xrcd = idr_read_xrcd(cmd->xrcd_handle, file->ucontext, &xrcd_uobj); | 2492 | attr.ext.xrc.xrcd = idr_read_xrcd(cmd->xrcd_handle, file->ucontext, &xrcd_uobj); |
| 2501 | if (!attr.ext.xrc.xrcd) { | 2493 | if (!attr.ext.xrc.xrcd) { |
| 2502 | ret = -EINVAL; | 2494 | ret = -EINVAL; |
| 2503 | goto err_put_cq; | 2495 | goto err; |
| 2504 | } | 2496 | } |
| 2505 | 2497 | ||
| 2506 | obj->uxrcd = container_of(xrcd_uobj, struct ib_uxrcd_object, uobject); | 2498 | obj->uxrcd = container_of(xrcd_uobj, struct ib_uxrcd_object, uobject); |
| 2507 | atomic_inc(&obj->uxrcd->refcnt); | 2499 | atomic_inc(&obj->uxrcd->refcnt); |
| 2500 | |||
| 2501 | attr.ext.xrc.cq = idr_read_cq(cmd->cq_handle, file->ucontext, 0); | ||
| 2502 | if (!attr.ext.xrc.cq) { | ||
| 2503 | ret = -EINVAL; | ||
| 2504 | goto err_put_xrcd; | ||
| 2505 | } | ||
| 2506 | } | ||
| 2507 | |||
| 2508 | pd = idr_read_pd(cmd->pd_handle, file->ucontext); | ||
| 2509 | if (!pd) { | ||
| 2510 | ret = -EINVAL; | ||
| 2511 | goto err_put_cq; | ||
| 2508 | } | 2512 | } |
| 2509 | 2513 | ||
| 2510 | attr.event_handler = ib_uverbs_srq_event_handler; | 2514 | attr.event_handler = ib_uverbs_srq_event_handler; |
| @@ -2581,17 +2585,17 @@ err_destroy: | |||
| 2581 | ib_destroy_srq(srq); | 2585 | ib_destroy_srq(srq); |
| 2582 | 2586 | ||
| 2583 | err_put: | 2587 | err_put: |
| 2584 | if (cmd->srq_type == IB_SRQT_XRC) { | 2588 | put_pd_read(pd); |
| 2585 | atomic_dec(&obj->uxrcd->refcnt); | ||
| 2586 | put_uobj_read(xrcd_uobj); | ||
| 2587 | } | ||
| 2588 | 2589 | ||
| 2589 | err_put_cq: | 2590 | err_put_cq: |
| 2590 | if (cmd->srq_type == IB_SRQT_XRC) | 2591 | if (cmd->srq_type == IB_SRQT_XRC) |
| 2591 | put_cq_read(attr.ext.xrc.cq); | 2592 | put_cq_read(attr.ext.xrc.cq); |
| 2592 | 2593 | ||
| 2593 | err_put_pd: | 2594 | err_put_xrcd: |
| 2594 | put_pd_read(pd); | 2595 | if (cmd->srq_type == IB_SRQT_XRC) { |
| 2596 | atomic_dec(&obj->uxrcd->refcnt); | ||
| 2597 | put_uobj_read(xrcd_uobj); | ||
| 2598 | } | ||
| 2595 | 2599 | ||
| 2596 | err: | 2600 | err: |
| 2597 | put_uobj_write(&obj->uevent.uobject); | 2601 | put_uobj_write(&obj->uevent.uobject); |
