* [PATCH] RDMA/rxe: Fix a couple IS_ERR() vs NULL bugs
@ 2025-06-25 15:22 Dan Carpenter
2025-06-25 18:03 ` yanjun.zhu
2025-06-26 12:14 ` Leon Romanovsky
0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2025-06-25 15:22 UTC (permalink / raw)
To: Zhu Yanjun
Cc: Jason Gunthorpe, Leon Romanovsky, Daisuke Matsuda, linux-rdma,
linux-kernel, kernel-janitors
The lookup_mr() function returns NULL on error. It never returns error
pointers.
Fixes: 9284bc34c773 ("RDMA/rxe: Enable asynchronous prefetch for ODP MRs")
Fixes: 3576b0df1588 ("RDMA/rxe: Implement synchronous prefetch for ODP MRs")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/infiniband/sw/rxe/rxe_odp.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/infiniband/sw/rxe/rxe_odp.c b/drivers/infiniband/sw/rxe/rxe_odp.c
index 01a59d3f8ed4..f58e3ec6252f 100644
--- a/drivers/infiniband/sw/rxe/rxe_odp.c
+++ b/drivers/infiniband/sw/rxe/rxe_odp.c
@@ -470,10 +470,10 @@ static int rxe_ib_prefetch_sg_list(struct ib_pd *ibpd,
mr = lookup_mr(pd, IB_ACCESS_LOCAL_WRITE,
sg_list[i].lkey, RXE_LOOKUP_LOCAL);
- if (IS_ERR(mr)) {
+ if (!mr) {
rxe_dbg_pd(pd, "mr with lkey %x not found\n",
sg_list[i].lkey);
- return PTR_ERR(mr);
+ return -EINVAL;
}
if (advice == IB_UVERBS_ADVISE_MR_ADVICE_PREFETCH_WRITE &&
@@ -535,8 +535,10 @@ static int rxe_ib_advise_mr_prefetch(struct ib_pd *ibpd,
/* Takes a reference, which will be released in the queued work */
mr = lookup_mr(pd, IB_ACCESS_LOCAL_WRITE,
sg_list[i].lkey, RXE_LOOKUP_LOCAL);
- if (IS_ERR(mr))
+ if (!mr) {
+ mr = ERR_PTR(-EINVAL);
goto err;
+ }
work->frags[i].io_virt = sg_list[i].addr;
work->frags[i].length = sg_list[i].length;
--
2.47.2
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] RDMA/rxe: Fix a couple IS_ERR() vs NULL bugs
2025-06-25 15:22 [PATCH] RDMA/rxe: Fix a couple IS_ERR() vs NULL bugs Dan Carpenter
@ 2025-06-25 18:03 ` yanjun.zhu
2025-06-25 18:16 ` Dan Carpenter
2025-06-26 12:14 ` Leon Romanovsky
1 sibling, 1 reply; 4+ messages in thread
From: yanjun.zhu @ 2025-06-25 18:03 UTC (permalink / raw)
To: Dan Carpenter, Zhu Yanjun
Cc: Jason Gunthorpe, Leon Romanovsky, Daisuke Matsuda, linux-rdma,
linux-kernel, kernel-janitors
On 6/25/25 8:22 AM, Dan Carpenter wrote:
> The lookup_mr() function returns NULL on error. It never returns error
> pointers.
Yes, I agree with you. However, this commit is intended to fix an issue
in the rdma-next tree. The corresponding repository is:
https://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git.
Therefore, the subject should be: [PATCH rdma-next]
This problem does not exist in the upstream Linux kernel.
Other than that, I have no issues with the commit.
Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Zhu Yanjun
>
> Fixes: 9284bc34c773 ("RDMA/rxe: Enable asynchronous prefetch for ODP MRs")
> Fixes: 3576b0df1588 ("RDMA/rxe: Implement synchronous prefetch for ODP MRs")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> drivers/infiniband/sw/rxe/rxe_odp.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/infiniband/sw/rxe/rxe_odp.c b/drivers/infiniband/sw/rxe/rxe_odp.c
> index 01a59d3f8ed4..f58e3ec6252f 100644
> --- a/drivers/infiniband/sw/rxe/rxe_odp.c
> +++ b/drivers/infiniband/sw/rxe/rxe_odp.c
> @@ -470,10 +470,10 @@ static int rxe_ib_prefetch_sg_list(struct ib_pd *ibpd,
> mr = lookup_mr(pd, IB_ACCESS_LOCAL_WRITE,
> sg_list[i].lkey, RXE_LOOKUP_LOCAL);
>
> - if (IS_ERR(mr)) {
> + if (!mr) {
> rxe_dbg_pd(pd, "mr with lkey %x not found\n",
> sg_list[i].lkey);
> - return PTR_ERR(mr);
> + return -EINVAL;
> }
>
> if (advice == IB_UVERBS_ADVISE_MR_ADVICE_PREFETCH_WRITE &&
> @@ -535,8 +535,10 @@ static int rxe_ib_advise_mr_prefetch(struct ib_pd *ibpd,
> /* Takes a reference, which will be released in the queued work */
> mr = lookup_mr(pd, IB_ACCESS_LOCAL_WRITE,
> sg_list[i].lkey, RXE_LOOKUP_LOCAL);
> - if (IS_ERR(mr))
> + if (!mr) {
> + mr = ERR_PTR(-EINVAL);
> goto err;
> + }
>
> work->frags[i].io_virt = sg_list[i].addr;
> work->frags[i].length = sg_list[i].length;
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] RDMA/rxe: Fix a couple IS_ERR() vs NULL bugs
2025-06-25 18:03 ` yanjun.zhu
@ 2025-06-25 18:16 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2025-06-25 18:16 UTC (permalink / raw)
To: yanjun.zhu
Cc: Zhu Yanjun, Jason Gunthorpe, Leon Romanovsky, Daisuke Matsuda,
linux-rdma, linux-kernel, kernel-janitors
On Wed, Jun 25, 2025 at 11:03:49AM -0700, yanjun.zhu wrote:
> On 6/25/25 8:22 AM, Dan Carpenter wrote:
> > The lookup_mr() function returns NULL on error. It never returns error
> > pointers.
>
> Yes, I agree with you. However, this commit is intended to fix an issue in
> the rdma-next tree. The corresponding repository is:
> https://git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git.
>
> Therefore, the subject should be: [PATCH rdma-next]
>
Yeah... I moved to a different machine and copied an older version
of my patching scripts. Normally, my scripts would put [PATCH next] in
the subject.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] RDMA/rxe: Fix a couple IS_ERR() vs NULL bugs
2025-06-25 15:22 [PATCH] RDMA/rxe: Fix a couple IS_ERR() vs NULL bugs Dan Carpenter
2025-06-25 18:03 ` yanjun.zhu
@ 2025-06-26 12:14 ` Leon Romanovsky
1 sibling, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2025-06-26 12:14 UTC (permalink / raw)
To: Zhu Yanjun, Dan Carpenter
Cc: Jason Gunthorpe, Daisuke Matsuda, linux-rdma, linux-kernel,
kernel-janitors
On Wed, 25 Jun 2025 10:22:23 -0500, Dan Carpenter wrote:
> The lookup_mr() function returns NULL on error. It never returns error
> pointers.
>
>
Applied, thanks!
[1/1] RDMA/rxe: Fix a couple IS_ERR() vs NULL bugs
https://git.kernel.org/rdma/rdma/c/19564a8576ac84
Best regards,
--
Leon Romanovsky <leon@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-06-26 12:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-25 15:22 [PATCH] RDMA/rxe: Fix a couple IS_ERR() vs NULL bugs Dan Carpenter
2025-06-25 18:03 ` yanjun.zhu
2025-06-25 18:16 ` Dan Carpenter
2025-06-26 12:14 ` Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox