[PATCH] Fix double-free and add comment in iscsi_free_task

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Submitting a patch a day before going on vacation is a bad idea.
Really sorry.

This patch fixes my previous patch to not crash due to double-free,
and also adds a comment.

Signed-off-by: Andy Grover <agrover@xxxxxxxxxx>
---
 usr/iscsi/iscsid.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index fe1780d..30bd13f 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -1227,7 +1227,11 @@ void iscsi_free_task(struct iscsi_task *task)
 	conn->tp->free_data_buf(conn, scsi_get_in_buffer(&task->scmd));
 	conn->tp->free_data_buf(conn, scsi_get_out_buffer(&task->scmd));
 
-	if ((task->data != scsi_get_in_buffer(&task->scmd)) ||
+	/*
+	 * If freeing task before in/out buffers are set, make sure to free
+	 * task->data or it leaks.
+	 */
+	if ((task->data != scsi_get_in_buffer(&task->scmd)) &&
 	    (task->data != scsi_get_out_buffer(&task->scmd)))
 		conn->tp->free_data_buf(conn, task->data);
 
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux