mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
658bcef619
commit
aaf1aef55f
|
@ -622,8 +622,10 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,
|
|||
obj->umem.virt_base = cmd.hca_va;
|
||||
|
||||
pd = idr_read_pd(cmd.pd_handle, file->ucontext);
|
||||
if (!pd)
|
||||
if (!pd) {
|
||||
ret = -EINVAL;
|
||||
goto err_release;
|
||||
}
|
||||
|
||||
mr = pd->device->reg_user_mr(pd, &obj->umem, cmd.access_flags, &udata);
|
||||
if (IS_ERR(mr)) {
|
||||
|
|
Loading…
Reference in New Issue