diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2014-02-23 07:52:44 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2014-02-23 19:19:23 -0500 |
commit | 10762e80489e73e2d52bf78e0869f253f42821bd (patch) | |
tree | 93a5e8ef29aa4bcffca00e8839ca87a103441075 /drivers/target | |
parent | 84197a36e9d78213da17b96fb838afcca4e150ea (diff) |
target/sbc: Fix sbc_dif_copy_prot addr offset bug
This patch fixes a bug in sbc_dif_copy_prot() where the updated addr
offset did not take into account the case where the associated
scatterlist had not been incremented.
This addresses the case where incoming protection scatterlists may
contain a length smaller than PAGE_SIZE across multiple entires,
when the target protection scatterlists are always being explicitly
filled up to PAGE_SIZE before adding another entry.
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Sagi Grimberg <sagig@mellanox.com>
Cc: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r-- | drivers/target/target_core_sbc.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index a4489444ffbc..ef1a58a134aa 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c | |||
@@ -1074,7 +1074,7 @@ sbc_dif_copy_prot(struct se_cmd *cmd, unsigned int sectors, bool read, | |||
1074 | struct scatterlist *psg; | 1074 | struct scatterlist *psg; |
1075 | void *paddr, *addr; | 1075 | void *paddr, *addr; |
1076 | unsigned int i, len, left; | 1076 | unsigned int i, len, left; |
1077 | unsigned int offset = 0; | 1077 | unsigned int offset = sg_off; |
1078 | 1078 | ||
1079 | left = sectors * dev->prot_length; | 1079 | left = sectors * dev->prot_length; |
1080 | 1080 | ||
@@ -1084,11 +1084,10 @@ sbc_dif_copy_prot(struct se_cmd *cmd, unsigned int sectors, bool read, | |||
1084 | if (offset >= sg->length) { | 1084 | if (offset >= sg->length) { |
1085 | sg = sg_next(sg); | 1085 | sg = sg_next(sg); |
1086 | offset = 0; | 1086 | offset = 0; |
1087 | sg_off = sg->offset; | ||
1088 | } | 1087 | } |
1089 | 1088 | ||
1090 | paddr = kmap_atomic(sg_page(psg)) + psg->offset; | 1089 | paddr = kmap_atomic(sg_page(psg)) + psg->offset; |
1091 | addr = kmap_atomic(sg_page(sg)) + sg_off; | 1090 | addr = kmap_atomic(sg_page(sg)) + sg->offset + offset; |
1092 | 1091 | ||
1093 | if (read) | 1092 | if (read) |
1094 | memcpy(paddr, addr, len); | 1093 | memcpy(paddr, addr, len); |