Skip to content

Commit 12d5a43

Browse files
tangwenjiNicholas Bellinger
authored andcommitted
iscsi-target: fix memory leak in lio_target_tiqn_addtpg()
tpg must free when call core_tpg_register() return fail Signed-off-by: tangwenji <[email protected]> Signed-off-by: Nicholas Bellinger <[email protected]>
1 parent 24528f0 commit 12d5a43

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/target/iscsi/iscsi_target_configfs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ static struct se_portal_group *lio_target_tiqn_addtpg(
11231123

11241124
ret = core_tpg_register(wwn, &tpg->tpg_se_tpg, SCSI_PROTOCOL_ISCSI);
11251125
if (ret < 0)
1126-
return NULL;
1126+
goto free_out;
11271127

11281128
ret = iscsit_tpg_add_portal_group(tiqn, tpg);
11291129
if (ret != 0)
@@ -1135,6 +1135,7 @@ static struct se_portal_group *lio_target_tiqn_addtpg(
11351135
return &tpg->tpg_se_tpg;
11361136
out:
11371137
core_tpg_deregister(&tpg->tpg_se_tpg);
1138+
free_out:
11381139
kfree(tpg);
11391140
return NULL;
11401141
}

0 commit comments

Comments
 (0)