diff mbox series

[for-rc] RDMA/bnxt_re: Fix to drop reference to the mmap entry in case of error

Message ID 20250104061519.2540178-1-kalesh-anakkur.purayil@broadcom.com (mailing list archive)
State Accepted
Headers show
Series [for-rc] RDMA/bnxt_re: Fix to drop reference to the mmap entry in case of error | expand

Commit Message

Kalesh AP Jan. 4, 2025, 6:15 a.m. UTC
In the error handling path of bnxt_re_mmap(), driver should invoke
rdma_user_mmap_entry_put() to free the reference of mmap entry in case
the error happens after rdma_user_mmap_entry_get was called.

Fixes: ea2224857882 ("RDMA/bnxt_re: Update alloc_page uapi for pacing")
Reviewed-by: Saravanan Vajravel <saravanan.vajravel@broadcom.com>
Reviewed-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
---
 drivers/infiniband/hw/bnxt_re/ib_verbs.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Leon Romanovsky Jan. 5, 2025, 11:52 a.m. UTC | #1
On Sat, 04 Jan 2025 11:45:19 +0530, Kalesh AP wrote:
> In the error handling path of bnxt_re_mmap(), driver should invoke
> rdma_user_mmap_entry_put() to free the reference of mmap entry in case
> the error happens after rdma_user_mmap_entry_get was called.
> 
> 

Applied, thanks!

[1/1] RDMA/bnxt_re: Fix to drop reference to the mmap entry in case of error
      https://git.kernel.org/rdma/rdma/c/c84f0f4f49d816

Best regards,
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
index e3d26bd6de05..1ff2e176b036 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -4467,9 +4467,10 @@  int bnxt_re_mmap(struct ib_ucontext *ib_uctx, struct vm_area_struct *vma)
 	case BNXT_RE_MMAP_TOGGLE_PAGE:
 		/* Driver doesn't expect write access for user space */
 		if (vma->vm_flags & VM_WRITE)
-			return -EFAULT;
-		ret = vm_insert_page(vma, vma->vm_start,
-				     virt_to_page((void *)bnxt_entry->mem_offset));
+			ret = -EFAULT;
+		else
+			ret = vm_insert_page(vma, vma->vm_start,
+					     virt_to_page((void *)bnxt_entry->mem_offset));
 		break;
 	default:
 		ret = -EINVAL;