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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user