Skip to content

Commit 9127169

Browse files
Bob Pearsonmartinkpetersen
authored andcommitted
scsi: target: core: Fix error path in target_setup_session()
In the error exits in target_setup_session(), if a branch is taken to free_sess: transport_free_session() may call to target_free_cmd_counter() and then fall through to call target_free_cmd_counter() a second time. This can, and does, sometimes cause seg faults since the data field in cmd_cnt->refcnt has been freed in the first call. Fix this problem by simply returning after the call to transport_free_session(). The second call is redundant for those cases. Fixes: 4edba7e ("scsi: target: Move cmd counter allocation") Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com> Link: https://lore.kernel.org/r/20230613144259.12890-1-rpearsonhpe@gmail.com Reviewed-by: Mike Christie <michael.christie@oracle.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 31d16e7 commit 9127169

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/target/target_core_transport.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,8 @@ target_setup_session(struct se_portal_group *tpg,
504504

505505
free_sess:
506506
transport_free_session(sess);
507+
return ERR_PTR(rc);
508+
507509
free_cnt:
508510
target_free_cmd_counter(cmd_cnt);
509511
return ERR_PTR(rc);

0 commit comments

Comments
 (0)