summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorVarun Prakash <varun@chelsio.com>2017-07-23 20:03:33 +0530
committerNicholas Bellinger <nab@linux-iscsi.org>2017-07-30 15:31:34 -0700
commitea8dc5b4cd2195ee582cae28afa4164c6dea1738 (patch)
tree55b2a54d2ccb2213d5cf633306b7ccf9fd8dfda6 /drivers
parent66b59f9b1f41ee61eb4862bbcfc1e7db5298ba9e (diff)
downloadlinux-stable-ea8dc5b4cd2195ee582cae28afa4164c6dea1738.tar.gz
linux-stable-ea8dc5b4cd2195ee582cae28afa4164c6dea1738.tar.bz2
linux-stable-ea8dc5b4cd2195ee582cae28afa4164c6dea1738.zip
iscsi-target: fix memory leak in iscsit_setup_text_cmd()
On receiving text request iscsi-target allocates buffer for payload in iscsit_handle_text_cmd() and assigns buffer pointer to cmd->text_in_ptr, this buffer is currently freed in iscsit_release_cmd(), if iscsi-target sets 'C' bit in text response then it will receive another text request from the initiator with ttt != 0xffffffff in this case iscsi-target will find cmd using itt and call iscsit_setup_text_cmd() which will set cmd->text_in_ptr to NULL without freeing previously allocated buffer. This patch fixes this issue by calling kfree(cmd->text_in_ptr) in iscsit_setup_text_cmd() before assigning NULL to it. For the first text request cmd->text_in_ptr is NULL as cmd is memset to 0 in iscsit_allocate_cmd(). Signed-off-by: Varun Prakash <varun@chelsio.com> Cc: <stable@vger.kernel.org> # 4.0+ Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/target/iscsi/iscsi_target.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 74e4975dd1b1..2688918b879a 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -2167,6 +2167,7 @@ iscsit_setup_text_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
cmd->cmd_sn = be32_to_cpu(hdr->cmdsn);
cmd->exp_stat_sn = be32_to_cpu(hdr->exp_statsn);
cmd->data_direction = DMA_NONE;
+ kfree(cmd->text_in_ptr);
cmd->text_in_ptr = NULL;
return 0;