From f2f42547bd45d6dba09b85fd8ef19b0726c4af2e Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Fri, 23 Nov 2012 16:37:56 +0100 Subject: [PATCH] ISCSI fix leaked memory report As long as we have no struct iscsi_task we cannot track the free() of data.indata buffer. This leads to a leaked memory report in iscsi_context_destroy(). We fix this by assuming it has been freed when we pass it it to scsi_task. Signed-off-by: Peter Lieven --- lib/iscsi-command.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/iscsi-command.c b/lib/iscsi-command.c index efe23de..fd03d8b 100644 --- a/lib/iscsi-command.c +++ b/lib/iscsi-command.c @@ -377,6 +377,12 @@ iscsi_process_scsi_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu, } } + /* the pdu->datain.data was malloc'ed by iscsi_malloc, + as long as we have no struct iscsi_task we cannot track + the free'ing of this buffer which is currently + done in scsi_free_scsi_task() */ + if (pdu->indata.data != NULL) iscsi->frees++; + pdu->indata.data = NULL; pdu->indata.size = 0; @@ -511,6 +517,12 @@ iscsi_process_scsi_data_in(struct iscsi_context *iscsi, struct iscsi_pdu *pdu, task->datain.data = pdu->indata.data; task->datain.size = pdu->indata.size; + /* the pdu->indata.data was malloc'ed by iscsi_malloc, + as long as we have no struct iscsi_task we cannot track + the free'ing of this buffer which is currently + done in scsi_free_scsi_task() */ + if (pdu->indata.data != NULL) iscsi->frees++; + pdu->indata.data = NULL; pdu->indata.size = 0;