libiscsi/0022-init-fix-memory-leak-in-iscsi_create_context.patch

32 lines
880 B
Diff
Raw Permalink Normal View History

From a391176a6dece09454672c6522778d6513e90fb4 Mon Sep 17 00:00:00 2001
From: zhenwei pi <pizhenwei@bytedance.com>
Date: Tue, 25 Feb 2020 22:35:54 +0800
Subject: [PATCH] init: fix memory leak in iscsi_create_context
iscsi instance is allocated in iscsi_create_context, after we return
NULL, nobody could handle it anymore.
Currently we can't hit this logic, anyway we still fix this.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
---
lib/init.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/init.c b/lib/init.c
index 13098f0..f3e2e13 100644
--- a/lib/init.c
+++ b/lib/init.c
@@ -218,7 +218,7 @@ iscsi_create_context(const char *initiator_name)
/* initalize transport of context */
if (iscsi_init_transport(iscsi, TCP_TRANSPORT)) {
- iscsi_set_error(iscsi, "Failed allocating transport");
+ free(iscsi);
return NULL;
}
--
2.35.3