Commit 05ea4968 authored by Nicholas Bellinger's avatar Nicholas Bellinger Committed by Greg Kroah-Hartman

iscsi-target: Fix iscsit_alloc_buffs() failure cases

commit d335e605 upstream.

Make iscsit_alloc_buffs() failure case for page_alloc_failed use correct
__free_page() SGL pointer, and return -ENOMEM for iscsit_allocate_iovecs
failure to push se_cmd->t_mem_sg release into iscsit_release_cmd()
callback during iscsit_add_reject_from_cmd() connection reset.

Also drop cmd->t_mem_sg = NULL assignment from page_alloc_failed
failure case.
Reported-by: default avatarRoland Dreier <roland@purestorage.com>
Cc: Andy Grover <agrover@redhat.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent bb9ed4f0
...@@ -781,7 +781,7 @@ static int iscsit_alloc_buffs(struct iscsi_cmd *cmd) ...@@ -781,7 +781,7 @@ static int iscsit_alloc_buffs(struct iscsi_cmd *cmd)
struct scatterlist *sgl; struct scatterlist *sgl;
u32 length = cmd->se_cmd.data_length; u32 length = cmd->se_cmd.data_length;
int nents = DIV_ROUND_UP(length, PAGE_SIZE); int nents = DIV_ROUND_UP(length, PAGE_SIZE);
int i = 0, ret; int i = 0, j = 0, ret;
/* /*
* If no SCSI payload is present, allocate the default iovecs used for * If no SCSI payload is present, allocate the default iovecs used for
* iSCSI PDU Header * iSCSI PDU Header
...@@ -822,17 +822,15 @@ static int iscsit_alloc_buffs(struct iscsi_cmd *cmd) ...@@ -822,17 +822,15 @@ static int iscsit_alloc_buffs(struct iscsi_cmd *cmd)
*/ */
ret = iscsit_allocate_iovecs(cmd); ret = iscsit_allocate_iovecs(cmd);
if (ret < 0) if (ret < 0)
goto page_alloc_failed; return -ENOMEM;
return 0; return 0;
page_alloc_failed: page_alloc_failed:
while (i >= 0) { while (j < i)
__free_page(sg_page(&sgl[i])); __free_page(sg_page(&sgl[j++]));
i--;
} kfree(sgl);
kfree(cmd->t_mem_sg);
cmd->t_mem_sg = NULL;
return -ENOMEM; return -ENOMEM;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment