[stgt] [PATCH] tgtd: fix memory leaks at it_nexus_create()

Ryusuke Konishi konishi.ryusuke at lab.ntt.co.jp
Sun Dec 8 19:32:19 CET 2013


The it_nexus_create function exits without freeing it_nexus_lu_info
struct nor it_nexus struct at error paths.

This fixes the leak bugs.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke at lab.ntt.co.jp>
---
 usr/target.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/usr/target.c b/usr/target.c
index 6968e76..f4c5b4e 100644
--- a/usr/target.c
+++ b/usr/target.c
@@ -321,8 +321,10 @@ int it_nexus_create(int tid, uint64_t itn_id, int host_no, char *info)
 		INIT_LIST_HEAD(&itn_lu->pending_ua_sense_list);
 
 		ret = ua_sense_add(itn_lu, ASC_POWERON_RESET);
-		if (ret)
+		if (ret) {
+			free(itn_lu);
 			goto out;
+		}
 
 		list_add_tail(&itn_lu->lu_itl_info_siblings,
 			      &lu->lu_itl_info_list);
@@ -338,6 +340,7 @@ int it_nexus_create(int tid, uint64_t itn_id, int host_no, char *info)
 	return 0;
 out:
 	it_nexus_del_lu_info(itn);
+	free(itn);
 	return -ENOMEM;
 }
 
-- 
1.7.9.3

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list