[stgt] [PATCH] Fix double-free and add comment in iscsi_free_task
Andy Grover
agrover at redhat.com
Tue Aug 20 00:15:23 CEST 2013
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 at redhat.com>
---
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 at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
More information about the stgt
mailing list