test-tool: avoid use-after-free on iscsi_logout_sync

iscsi_logout_sync in lu_reset_simple will still refer to wtask in the
case that we bail out due to reconnect failure.

abort_simple would sometimes refer to wtask during iscsi_logout_sync,
even if the test passed.

Signed-off-by: Khazhismel Kumykov <khazhy@google.com>
This commit is contained in:
Khazhismel Kumykov
2019-11-08 17:36:40 -08:00
committed by Ronnie Sahlberg
parent 88f67e8cf8
commit 2b9c928bce
2 changed files with 6 additions and 7 deletions

View File

@@ -199,10 +199,9 @@ test_async_abort_simple(void)
CU_FAIL("unexpected WRITE/ABORT state"); CU_FAIL("unexpected WRITE/ABORT state");
} }
scsi_free_scsi_task(state.wtask);
/* Avoid that callbacks get invoked after this test finished */ /* Avoid that callbacks get invoked after this test finished */
iscsi_logout_sync(sd->iscsi_ctx); iscsi_logout_sync(sd->iscsi_ctx);
iscsi_destroy_context(sd->iscsi_ctx); iscsi_destroy_context(sd->iscsi_ctx);
scsi_free_scsi_task(state.wtask);
sd->iscsi_ctx = NULL; sd->iscsi_ctx = NULL;
} }

View File

@@ -196,10 +196,10 @@ test_async_lu_reset_simple(void)
} }
out: out:
scsi_free_scsi_task(state.wtask);
/* Avoid that callbacks get invoked after this test finished */ /* Avoid that callbacks get invoked after this test finished */
iscsi_logout_sync(sd->iscsi_ctx); iscsi_logout_sync(sd->iscsi_ctx);
iscsi_destroy_context(sd->iscsi_ctx); iscsi_destroy_context(sd->iscsi_ctx);
scsi_free_scsi_task(state.wtask);
sd->iscsi_ctx = NULL; sd->iscsi_ctx = NULL;
} }