diff mbox series

scsi: target: sbp: Fix memory leak in sbp_management_request_logout()

Message ID 20220526013839.471987-1-niejianglei2021@163.com (mailing list archive)
State Deferred
Headers show
Series scsi: target: sbp: Fix memory leak in sbp_management_request_logout() | expand

Commit Message

Jianglei Nie May 26, 2022, 1:38 a.m. UTC
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 <niejianglei2021@163.com>
---
 drivers/target/sbp/sbp_target.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

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;
 	}