All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] RDMA/rtrs: check before free
@ 2020-10-01  7:27 Gioh Kim
  2020-10-01  9:45 ` Jinpu Wang
  0 siblings, 1 reply; 2+ messages in thread
From: Gioh Kim @ 2020-10-01  7:27 UTC (permalink / raw)
  To: danil.kipnis, jinpu.wang; +Cc: linux-kernel, linux-rdma, Gioh Kim

From: Gioh Kim <gi-oh.kim@cloud.ionos.com>

If rtrs_iu_alloc failed to allocate buffer or map dma,
there are some allocated addresses and some NULL addresses
in the array. rtrs_iu_free should check data before free.

Signed-off-by: Gioh Kim <gi-oh.kim@cloud.ionos.com>
---
 drivers/infiniband/ulp/rtrs/rtrs.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c
index 5163e662f86f..ca2d2d3e4192 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs.c
@@ -61,8 +61,12 @@ void rtrs_iu_free(struct rtrs_iu *ius, struct ib_device *ibdev, u32 queue_size)
 
 	for (i = 0; i < queue_size; i++) {
 		iu = &ius[i];
-		ib_dma_unmap_single(ibdev, iu->dma_addr, iu->size, iu->direction);
-		kfree(iu->buf);
+		if (iu->dma_addr) {
+			ib_dma_unmap_single(ibdev, iu->dma_addr, iu->size, iu->direction);
+		}
+		if (iu->buf) {
+			kfree(iu->buf);
+		}
 	}
 	kfree(ius);
 }
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-01  9:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-01  7:27 [PATCH 2/2] RDMA/rtrs: check before free Gioh Kim
2020-10-01  9:45 ` Jinpu Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.