* [PATCH] IB/rxe: ODP: Fix missing umem_odp->umem_mutex unlock
@ 2025-12-26 9:41 Li Zhijian
2025-12-27 1:05 ` Zhu Yanjun
2025-12-30 9:28 ` Leon Romanovsky
0 siblings, 2 replies; 5+ messages in thread
From: Li Zhijian @ 2025-12-26 9:41 UTC (permalink / raw)
To: linux-rdma
Cc: linux-kernel, zyjzyj2000, jgg, leon, Daisuke Matsuda, Li Zhijian
rxe_odp_map_range_and_lock() should unlock umem_odp->umem_mutex on error.
Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
---
drivers/infiniband/sw/rxe/rxe_odp.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/sw/rxe/rxe_odp.c b/drivers/infiniband/sw/rxe/rxe_odp.c
index 8b6a8b064d3c..d22b08da2713 100644
--- a/drivers/infiniband/sw/rxe/rxe_odp.c
+++ b/drivers/infiniband/sw/rxe/rxe_odp.c
@@ -178,8 +178,10 @@ static int rxe_odp_map_range_and_lock(struct rxe_mr *mr, u64 iova, int length, u
return err;
need_fault = rxe_check_pagefault(umem_odp, iova, length);
- if (need_fault)
+ if (need_fault) {
+ mutex_unlock(&umem_odp->umem_mutex);
return -EFAULT;
+ }
}
return 0;
--
2.41.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] IB/rxe: ODP: Fix missing umem_odp->umem_mutex unlock
2025-12-26 9:41 [PATCH] IB/rxe: ODP: Fix missing umem_odp->umem_mutex unlock Li Zhijian
@ 2025-12-27 1:05 ` Zhu Yanjun
2025-12-30 9:27 ` Leon Romanovsky
2025-12-30 9:28 ` Leon Romanovsky
1 sibling, 1 reply; 5+ messages in thread
From: Zhu Yanjun @ 2025-12-27 1:05 UTC (permalink / raw)
To: Li Zhijian, linux-rdma
Cc: linux-kernel, zyjzyj2000, jgg, leon, Daisuke Matsuda
在 2025/12/26 1:41, Li Zhijian 写道:
> rxe_odp_map_range_and_lock() should unlock umem_odp->umem_mutex on error.
>
> Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
> ---
> drivers/infiniband/sw/rxe/rxe_odp.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/sw/rxe/rxe_odp.c b/drivers/infiniband/sw/rxe/rxe_odp.c
> index 8b6a8b064d3c..d22b08da2713 100644
> --- a/drivers/infiniband/sw/rxe/rxe_odp.c
> +++ b/drivers/infiniband/sw/rxe/rxe_odp.c
> @@ -178,8 +178,10 @@ static int rxe_odp_map_range_and_lock(struct rxe_mr *mr, u64 iova, int length, u
> return err;
>
160 static int rxe_odp_map_range_and_lock(struct rxe_mr *mr, u64 iova,
int length, u32 flags)
161 {
162 struct ib_umem_odp *umem_odp = to_ib_umem_odp(mr->umem);
163 bool need_fault;
164 int err;
165
166 if (unlikely(length < 1))
167 return -EINVAL;
168
169 mutex_lock(&umem_odp->umem_mutex);
170
171 need_fault = rxe_check_pagefault(umem_odp, iova, length);
172 if (need_fault) {
173 mutex_unlock(&umem_odp->umem_mutex);
174
175 /* umem_mutex is locked on success. */
176 err = rxe_odp_do_pagefault_and_lock(mr, iova, length,
177 flags);
178 if (err < 0)
179 return err;
If the function rxe_odp_do_pagefault_and_lock() succeeds and run here,
the mutex lock umem_mutex should be held.
Thus, if rxe_check_pagefault fails, the mutex lock umem_mutex should be
released.
as such, I am fine with this.
But IMO, the commit log is too simple. The above explanations should be
added into the commit logs.
Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Zhu Yanjun
180
181 need_fault = rxe_check_pagefault(umem_odp, iova, length);
182 if (need_fault)
183 return -EFAULT;
184 }
185
186 return 0;
187 }
> need_fault = rxe_check_pagefault(umem_odp, iova, length);
> - if (need_fault)
> + if (need_fault) {
> + mutex_unlock(&umem_odp->umem_mutex);
> return -EFAULT;
> + }
> }
>
> return 0;
--
Best Regards,
Yanjun.Zhu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] IB/rxe: ODP: Fix missing umem_odp->umem_mutex unlock
2025-12-27 1:05 ` Zhu Yanjun
@ 2025-12-30 9:27 ` Leon Romanovsky
2025-12-30 15:24 ` Zhu Yanjun
0 siblings, 1 reply; 5+ messages in thread
From: Leon Romanovsky @ 2025-12-30 9:27 UTC (permalink / raw)
To: Zhu Yanjun
Cc: Li Zhijian, linux-rdma, linux-kernel, zyjzyj2000, jgg,
Daisuke Matsuda
On Fri, Dec 26, 2025 at 05:05:09PM -0800, Zhu Yanjun wrote:
>
> 在 2025/12/26 1:41, Li Zhijian 写道:
> > rxe_odp_map_range_and_lock() should unlock umem_odp->umem_mutex on error.
> >
> > Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
> > ---
> > drivers/infiniband/sw/rxe/rxe_odp.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/infiniband/sw/rxe/rxe_odp.c b/drivers/infiniband/sw/rxe/rxe_odp.c
> > index 8b6a8b064d3c..d22b08da2713 100644
> > --- a/drivers/infiniband/sw/rxe/rxe_odp.c
> > +++ b/drivers/infiniband/sw/rxe/rxe_odp.c
> > @@ -178,8 +178,10 @@ static int rxe_odp_map_range_and_lock(struct rxe_mr *mr, u64 iova, int length, u
> > return err;
> 160 static int rxe_odp_map_range_and_lock(struct rxe_mr *mr, u64 iova, int
> length, u32 flags)
> 161 {
> 162 struct ib_umem_odp *umem_odp = to_ib_umem_odp(mr->umem);
> 163 bool need_fault;
> 164 int err;
> 165
> 166 if (unlikely(length < 1))
> 167 return -EINVAL;
> 168
> 169 mutex_lock(&umem_odp->umem_mutex);
> 170
> 171 need_fault = rxe_check_pagefault(umem_odp, iova, length);
> 172 if (need_fault) {
> 173 mutex_unlock(&umem_odp->umem_mutex);
> 174
> 175 /* umem_mutex is locked on success. */
> 176 err = rxe_odp_do_pagefault_and_lock(mr, iova, length,
> 177 flags);
> 178 if (err < 0)
>
> 179 return err;
>
> If the function rxe_odp_do_pagefault_and_lock() succeeds and run here, the
> mutex lock umem_mutex should be held.
>
> Thus, if rxe_check_pagefault fails, the mutex lock umem_mutex should be
> released.
>
> as such, I am fine with this.
>
> But IMO, the commit log is too simple. The above explanations should be
> added into the commit logs.
>
> Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>
I made a few adjustments to the commit message, added a Fixes tag, included
your Reviewed-by, and applied the patch.
Thanks
>
> Zhu Yanjun
>
> 180
> 181 need_fault = rxe_check_pagefault(umem_odp, iova, length);
> 182 if (need_fault)
> 183 return -EFAULT;
> 184 }
> 185
> 186 return 0;
> 187 }
>
> > need_fault = rxe_check_pagefault(umem_odp, iova, length);
> > - if (need_fault)
> > + if (need_fault) {
> > + mutex_unlock(&umem_odp->umem_mutex);
> > return -EFAULT;
> > + }
> > }
> > return 0;
>
> --
> Best Regards,
> Yanjun.Zhu
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] IB/rxe: ODP: Fix missing umem_odp->umem_mutex unlock
2025-12-26 9:41 [PATCH] IB/rxe: ODP: Fix missing umem_odp->umem_mutex unlock Li Zhijian
2025-12-27 1:05 ` Zhu Yanjun
@ 2025-12-30 9:28 ` Leon Romanovsky
1 sibling, 0 replies; 5+ messages in thread
From: Leon Romanovsky @ 2025-12-30 9:28 UTC (permalink / raw)
To: linux-rdma, Li Zhijian; +Cc: linux-kernel, zyjzyj2000, jgg, Daisuke Matsuda
On Fri, 26 Dec 2025 17:41:12 +0800, Li Zhijian wrote:
> rxe_odp_map_range_and_lock() should unlock umem_odp->umem_mutex on error.
>
>
Applied, thanks!
[1/1] IB/rxe: ODP: Fix missing umem_odp->umem_mutex unlock
https://git.kernel.org/rdma/rdma/c/3c68cf68233e55
Best regards,
--
Leon Romanovsky <leon@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] IB/rxe: ODP: Fix missing umem_odp->umem_mutex unlock
2025-12-30 9:27 ` Leon Romanovsky
@ 2025-12-30 15:24 ` Zhu Yanjun
0 siblings, 0 replies; 5+ messages in thread
From: Zhu Yanjun @ 2025-12-30 15:24 UTC (permalink / raw)
To: Leon Romanovsky
Cc: Li Zhijian, linux-rdma, linux-kernel, zyjzyj2000, jgg,
Daisuke Matsuda
在 2025/12/30 1:27, Leon Romanovsky 写道:
> I made a few adjustments to the commit message, added a Fixes tag, included
> your Reviewed-by, and applied the patch.
Thanks a lot.
Zhu Yanjun
>
>
>
--
Best Regards,
Yanjun.Zhu
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-12-30 15:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-26 9:41 [PATCH] IB/rxe: ODP: Fix missing umem_odp->umem_mutex unlock Li Zhijian
2025-12-27 1:05 ` Zhu Yanjun
2025-12-30 9:27 ` Leon Romanovsky
2025-12-30 15:24 ` Zhu Yanjun
2025-12-30 9:28 ` Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).