test tool: Fix a memory leak in testunitready_clear_ua()

Avoid leaking 'task' if task->status != SCSI_STATUS_GOOD.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
This commit is contained in:
Bart Van Assche
2013-10-20 14:58:56 +02:00
committed by Ronnie Sahlberg
parent 9f89f220f5
commit 9c7092e85c

View File

@@ -1607,7 +1607,7 @@ int
testunitready_clear_ua(struct iscsi_context *iscsi, int lun)
{
struct scsi_task *task;
int ret = -1;
logging(LOG_VERBOSE,
"Send TESTUNITREADY (To Clear Possible UA) init=%s",
@@ -1618,18 +1618,21 @@ testunitready_clear_ua(struct iscsi_context *iscsi, int lun)
logging(LOG_NORMAL,
"[FAILED] Failed to send TESTUNITREADY command: %s",
iscsi_get_error(iscsi));
return -1;
goto out;
}
if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_NORMAL,
"[INFO] TESTUNITREADY command: failed with sense. %s",
iscsi_get_error(iscsi));
return -1;
goto out;
}
scsi_free_scsi_task(task);
logging(LOG_VERBOSE, "[OK] TESTUNITREADY does not return unit "
"attention.");
return 0;
ret = 0;
out:
scsi_free_scsi_task(task);
return ret;
}
int