2022-05-28 20:23:01

by Jianglei Nie

[permalink] [raw]
Subject: [PATCH] scsi: target: sbp: Fix memory leak in sbp_management_request_logout()

When req->node_addr != login->sess->node_id, sbp_management_request
_logout() returns without releasing the login, which may lead to a
potential memory leak.

We can fix it by calling sbp_login_release() before the function returns.

Signed-off-by: Jianglei Nie <[email protected]>
---
drivers/target/sbp/sbp_target.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
index 504670994fb4..76f3ec58a24b 100644
--- a/drivers/target/sbp/sbp_target.c
+++ b/drivers/target/sbp/sbp_target.c
@@ -575,6 +575,7 @@ static void sbp_management_request_logout(
req->status.status = cpu_to_be32(
STATUS_BLOCK_RESP(STATUS_RESP_REQUEST_COMPLETE) |
STATUS_BLOCK_SBP_STATUS(SBP_STATUS_ACCESS_DENIED));
+ sbp_login_release(login, true);
return;
}

--
2.25.1