Improve robustness of the code that restores .queue_pdu()

In my tests I hit a stack overflow caused by infinite recursion of
.queue_pdu() calls, caused by .queue_pdu() not being restored in an
error path. Make the approach for restoring .queue_pdu() more robust.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
This commit is contained in:
Bart Van Assche
2019-11-03 14:59:11 -08:00
parent 10599fcd4f
commit cc3ddbff42
10 changed files with 19 additions and 52 deletions
+4
View File
@@ -730,6 +730,7 @@ static struct test_family families[] = {
*/
struct scsi_task *task;
unsigned char *read_write_buf;
int (*orig_queue_pdu)(struct iscsi_context *iscsi, struct iscsi_pdu *pdu);
static void
print_usage(void)
@@ -825,11 +826,14 @@ test_setup(void)
{
task = NULL;
read_write_buf = NULL;
orig_queue_pdu = sd->iscsi_ctx ? sd->iscsi_ctx->drv->queue_pdu : NULL;
}
void
test_teardown(void)
{
if (sd->iscsi_ctx)
sd->iscsi_ctx->drv->queue_pdu = orig_queue_pdu;
free(read_write_buf);
read_write_buf = NULL;
scsi_free_scsi_task(task);