Message ID | 20220805183153.32007-3-rpearsonhpe@gmail.com (mailing list archive) |
---|---|
State | Rejected |
Delegated to: | Jason Gunthorpe |
Headers | show |
Series | RDMA/rxe: Fix error paths in MR alloc routines | expand |
> -----Original Message----- > From: Bob Pearson <rpearsonhpe@gmail.com> > Sent: Saturday, August 6, 2022 2:32 AM > To: jgg@nvidia.com; zyjzyj2000@gmail.com; Li, Zhijian/李 智坚 > <lizhijian@fujitsu.com>; jhack@hpe.com; linux-rdma@vger.kernel.org > Cc: Bob Pearson <rpearsonhpe@gmail.com> > Subject: [PATCH v5 for-next 2/2] RDMA/rxe: Test mr->umem before releasing > umem > > In rxe_mr_cleanup() test mr->umem before calling ib_umem_release() since in > some error paths it may not be set. > > Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com> > --- > drivers/infiniband/sw/rxe/rxe_mr.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c > b/drivers/infiniband/sw/rxe/rxe_mr.c > index af34f198e645..f0726e8ee855 100644 > --- a/drivers/infiniband/sw/rxe/rxe_mr.c > +++ b/drivers/infiniband/sw/rxe/rxe_mr.c > @@ -627,7 +627,9 @@ void rxe_mr_cleanup(struct rxe_pool_elem *elem) > int i; > > rxe_put(mr_pd(mr)); > - ib_umem_release(mr->umem); > + > + if (mr->umem) > + ib_umem_release(mr->umem); It's safe to pass a NULL to ib_umem_release() where it has a such check. Thanks Zhijian > > if (mr->map) { > for (i = 0; i < mr->num_map; i++) > -- > 2.34.1
On 8/22/22 00:50, lizhijian@fujitsu.com wrote: > > >> -----Original Message----- >> From: Bob Pearson <rpearsonhpe@gmail.com> >> Sent: Saturday, August 6, 2022 2:32 AM >> To: jgg@nvidia.com; zyjzyj2000@gmail.com; Li, Zhijian/李 智坚 >> <lizhijian@fujitsu.com>; jhack@hpe.com; linux-rdma@vger.kernel.org >> Cc: Bob Pearson <rpearsonhpe@gmail.com> >> Subject: [PATCH v5 for-next 2/2] RDMA/rxe: Test mr->umem before releasing >> umem >> >> In rxe_mr_cleanup() test mr->umem before calling ib_umem_release() since in >> some error paths it may not be set. >> >> Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com> >> --- >> drivers/infiniband/sw/rxe/rxe_mr.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c >> b/drivers/infiniband/sw/rxe/rxe_mr.c >> index af34f198e645..f0726e8ee855 100644 >> --- a/drivers/infiniband/sw/rxe/rxe_mr.c >> +++ b/drivers/infiniband/sw/rxe/rxe_mr.c >> @@ -627,7 +627,9 @@ void rxe_mr_cleanup(struct rxe_pool_elem *elem) >> int i; >> >> rxe_put(mr_pd(mr)); >> - ib_umem_release(mr->umem); >> + >> + if (mr->umem) >> + ib_umem_release(mr->umem); > > It's safe to pass a NULL to ib_umem_release() where it has a such check. > > > Thanks > Zhijian > >> >> if (mr->map) { >> for (i = 0; i < mr->num_map; i++) >> -- >> 2.34.1 > OK we can just drop this patch. Bob
diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c index af34f198e645..f0726e8ee855 100644 --- a/drivers/infiniband/sw/rxe/rxe_mr.c +++ b/drivers/infiniband/sw/rxe/rxe_mr.c @@ -627,7 +627,9 @@ void rxe_mr_cleanup(struct rxe_pool_elem *elem) int i; rxe_put(mr_pd(mr)); - ib_umem_release(mr->umem); + + if (mr->umem) + ib_umem_release(mr->umem); if (mr->map) { for (i = 0; i < mr->num_map; i++)
In rxe_mr_cleanup() test mr->umem before calling ib_umem_release() since in some error paths it may not be set. Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com> --- drivers/infiniband/sw/rxe/rxe_mr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)