aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2007-02-22 16:16:51 -0500
committerRoland Dreier <rolandd@cisco.com>2007-02-22 16:16:51 -0500
commitaaf1aef55f50f53812871693692c7cbefcd57f39 (patch)
tree01a533c2f93dccda7176ce4bf3d68c3212a8c0b4
parent658bcef619f50d9eb6028452ff9e1ad4a96c2af9 (diff)
IB/uverbs: Return correct error for invalid PD in register MR
If no matching PD is found in ib_uverbs_reg_mr(), then the function jumps to err_release without setting the return value ret. This means that ret will hold the return value of the call to ib_umem_get() a few lines earlier; if the function reaches the point where it looks for the PD, we know that ib_umem_get() must have returned 0, so ib_uverbs_reg_mr() ends up return 0 for a bad PD ID. Fix this by setting ret to -EINVAL before jumping to the exit path when no PD is found. Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index df1efbc10882..4fd75afa6a3a 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -622,8 +622,10 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,
622 obj->umem.virt_base = cmd.hca_va; 622 obj->umem.virt_base = cmd.hca_va;
623 623
624 pd = idr_read_pd(cmd.pd_handle, file->ucontext); 624 pd = idr_read_pd(cmd.pd_handle, file->ucontext);
625 if (!pd) 625 if (!pd) {
626 ret = -EINVAL;
626 goto err_release; 627 goto err_release;
628 }
627 629
628 mr = pd->device->reg_user_mr(pd, &obj->umem, cmd.access_flags, &udata); 630 mr = pd->device->reg_user_mr(pd, &obj->umem, cmd.access_flags, &udata);
629 if (IS_ERR(mr)) { 631 if (IS_ERR(mr)) {