diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-02-23 20:28:43 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-02-25 17:37:50 -0500 |
commit | d335e6054db616bce3f040e659fa38440518ad1d (patch) | |
tree | f426c61320c4b323536a2b46203e17e5c6c3ea59 /drivers/target | |
parent | 33395fb8a13731c7ef7b175dbf5a4d8a6738fe6c (diff) |
iscsi-target: Fix iscsit_alloc_buffs() failure cases
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: Roland Dreier <roland@purestorage.com>
Cc: Andy Grover <agrover@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r-- | drivers/target/iscsi/iscsi_target.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index cecf951e420f..c3ef2f6f3740 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c | |||
@@ -780,7 +780,7 @@ static int iscsit_alloc_buffs(struct iscsi_cmd *cmd) | |||
780 | struct scatterlist *sgl; | 780 | struct scatterlist *sgl; |
781 | u32 length = cmd->se_cmd.data_length; | 781 | u32 length = cmd->se_cmd.data_length; |
782 | int nents = DIV_ROUND_UP(length, PAGE_SIZE); | 782 | int nents = DIV_ROUND_UP(length, PAGE_SIZE); |
783 | int i = 0, ret; | 783 | int i = 0, j = 0, ret; |
784 | /* | 784 | /* |
785 | * If no SCSI payload is present, allocate the default iovecs used for | 785 | * If no SCSI payload is present, allocate the default iovecs used for |
786 | * iSCSI PDU Header | 786 | * iSCSI PDU Header |
@@ -821,17 +821,15 @@ static int iscsit_alloc_buffs(struct iscsi_cmd *cmd) | |||
821 | */ | 821 | */ |
822 | ret = iscsit_allocate_iovecs(cmd); | 822 | ret = iscsit_allocate_iovecs(cmd); |
823 | if (ret < 0) | 823 | if (ret < 0) |
824 | goto page_alloc_failed; | 824 | return -ENOMEM; |
825 | 825 | ||
826 | return 0; | 826 | return 0; |
827 | 827 | ||
828 | page_alloc_failed: | 828 | page_alloc_failed: |
829 | while (i >= 0) { | 829 | while (j < i) |
830 | __free_page(sg_page(&sgl[i])); | 830 | __free_page(sg_page(&sgl[j++])); |
831 | i--; | 831 | |
832 | } | 832 | kfree(sgl); |
833 | kfree(cmd->t_mem_sg); | ||
834 | cmd->t_mem_sg = NULL; | ||
835 | return -ENOMEM; | 833 | return -ENOMEM; |
836 | } | 834 | } |
837 | 835 | ||