]> git.itanic.dy.fi Git - linux-stable/commit
scsi: target: core: Fix error path in target_setup_session()
authorBob Pearson <rpearsonhpe@gmail.com>
Tue, 13 Jun 2023 14:43:00 +0000 (09:43 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 Jun 2023 14:02:18 +0000 (16:02 +0200)
commit0c7d966f54a488cf412688de2d1b47783e612f7f
tree48b64d478c02ad91fc9d1621c68ac77d0a47fad6
parentb0ec36dddffb3e772dcad634f332a59c573c15a4
scsi: target: core: Fix error path in target_setup_session()

commit 91271699228bfc66f1bc8abc0327169dc156d854 upstream.

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: 4edba7e4a8f3 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/target/target_core_transport.c