From 9c7092e85cdcab8465cbd582b01f7e5d3d802e8b Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 20 Oct 2013 14:58:56 +0200 Subject: [PATCH] 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 --- test-tool/iscsi-support.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c index 3cccbe8..2a317cc 100644 --- a/test-tool/iscsi-support.c +++ b/test-tool/iscsi-support.c @@ -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