Skip to content

Commit

Permalink
target: fix possible memory leak in core_tpg_register()
Browse files Browse the repository at this point in the history
'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>
  • Loading branch information
Wei Yongjun authored and nablio3000 committed Mar 18, 2013
1 parent 7ac9ad1 commit 0fb889b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/target/target_core_tpg.c
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,8 @@ int core_tpg_register(

if (se_tpg->se_tpg_type == TRANSPORT_TPG_TYPE_NORMAL) {
if (core_tpg_setup_virtual_lun0(se_tpg) < 0) {
kfree(se_tpg);
array_free(se_tpg->tpg_lun_list,
TRANSPORT_MAX_LUNS_PER_TPG);
return -ENOMEM;
}
}
Expand Down

0 comments on commit 0fb889b

Please sign in to comment.