public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] infiniband: Fix a use after free in isert_connect_request
@ 2021-03-22 13:53 Lv Yunlong
  2021-03-22 14:27 ` Leon Romanovsky
  0 siblings, 1 reply; 5+ messages in thread
From: Lv Yunlong @ 2021-03-22 13:53 UTC (permalink / raw)
  To: sagi, dledford, jgg; +Cc: linux-rdma, target-devel, linux-kernel, Lv Yunlong

The device is got by isert_device_get() with refcount is 1,
and is assigned to isert_conn by isert_conn->device = device.
When isert_create_qp() failed, device will be freed with
isert_device_put().

Later, the device is used in isert_free_login_buf(isert_conn)
by the isert_conn->device->ib_device statement. My patch
exchanges the callees order to free the device late.

Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
---
 drivers/infiniband/ulp/isert/ib_isert.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
index 7305ed8976c2..d8a533e346b0 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.c
+++ b/drivers/infiniband/ulp/isert/ib_isert.c
@@ -473,10 +473,10 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
 
 out_destroy_qp:
 	isert_destroy_qp(isert_conn);
-out_conn_dev:
-	isert_device_put(device);
 out_rsp_dma_map:
 	isert_free_login_buf(isert_conn);
+out_conn_dev:
+	isert_device_put(device);
 out:
 	kfree(isert_conn);
 	rdma_reject(cma_id, NULL, 0, IB_CM_REJ_CONSUMER_DEFINED);
-- 
2.25.1



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

end of thread, other threads:[~2021-03-22 15:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-22 13:53 [PATCH] infiniband: Fix a use after free in isert_connect_request Lv Yunlong
2021-03-22 14:27 ` Leon Romanovsky
2021-03-22 14:51   ` lyl2019
2021-03-22 15:31     ` Leon Romanovsky
2021-03-22 15:50       ` lyl2019

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox