aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei Yongjun <yongjun_wei@trendmicro.com.cn>2013-03-15 05:19:26 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2013-03-18 15:45:52 -0400
commit0fb889b83186e54c0cfa79516599f2267fb553fb (patch)
tree8410aed12c23a81cdd838999b63108421d49a34d
parent7ac9ad11b2a5cf77a92b58ee6b672ad2fa155eb1 (diff)
target: fix possible memory leak in core_tpg_register()
'se_tpg->tpg_lun_list' is malloced in core_tpg_register() and should be freed before leaving from the error handling cases, otherwise it will cause memory leak. 'se_tpg' is malloced out of this function, and will be freed if we return error, so remove free for 'se_tpg'. Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r--drivers/target/target_core_tpg.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index 9169d6a5d7e4..aac9d2727e3c 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -711,7 +711,8 @@ int core_tpg_register(
711 711
712 if (se_tpg->se_tpg_type == TRANSPORT_TPG_TYPE_NORMAL) { 712 if (se_tpg->se_tpg_type == TRANSPORT_TPG_TYPE_NORMAL) {
713 if (core_tpg_setup_virtual_lun0(se_tpg) < 0) { 713 if (core_tpg_setup_virtual_lun0(se_tpg) < 0) {
714 kfree(se_tpg); 714 array_free(se_tpg->tpg_lun_list,
715 TRANSPORT_MAX_LUNS_PER_TPG);
715 return -ENOMEM; 716 return -ENOMEM;
716 } 717 }
717 } 718 }