Skip to content

Commit

Permalink
target/sbc: Fix sbc_dif_copy_prot addr offset bug
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Nicholas Bellinger committed Feb 24, 2014
1 parent 84197a3 commit 10762e8
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/target/target_core_sbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ sbc_dif_copy_prot(struct se_cmd *cmd, unsigned int sectors, bool read,
struct scatterlist *psg;
void *paddr, *addr;
unsigned int i, len, left;
unsigned int offset = 0;
unsigned int offset = sg_off;

left = sectors * dev->prot_length;

Expand All @@ -1084,11 +1084,10 @@ sbc_dif_copy_prot(struct se_cmd *cmd, unsigned int sectors, bool read,
if (offset >= sg->length) {
sg = sg_next(sg);
offset = 0;
sg_off = sg->offset;
}

paddr = kmap_atomic(sg_page(psg)) + psg->offset;
addr = kmap_atomic(sg_page(sg)) + sg_off;
addr = kmap_atomic(sg_page(sg)) + sg->offset + offset;

if (read)
memcpy(paddr, addr, len);
Expand Down

0 comments on commit 10762e8

Please sign in to comment.