浏览代码

crypto: mv_cesa - Fix situation where the dest sglist is organized differently than the source sglist

Bugfix for situations where the destination scatterlist has a different
buffer structure than the source scatterlist (e.g. source has one 2K
buffer and dest has 2 1K buffers)

Signed-off-by: Uri Simchoni <uri@jdland.co.il>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Uri Simchoni 15 年之前
父节点
当前提交
f565e67ec1
共有 1 个文件被更改,包括 9 次插入5 次删除
  1. 9 5
      drivers/crypto/mv_cesa.c

+ 9 - 5
drivers/crypto/mv_cesa.c

@@ -242,6 +242,8 @@ static void dequeue_complete_req(void)
 	struct ablkcipher_request *req = cpg->cur_req;
 	struct ablkcipher_request *req = cpg->cur_req;
 	void *buf;
 	void *buf;
 	int ret;
 	int ret;
+	int need_copy_len = cpg->p.crypt_len;
+	int sram_offset = 0;
 
 
 	cpg->p.total_req_bytes += cpg->p.crypt_len;
 	cpg->p.total_req_bytes += cpg->p.crypt_len;
 	do {
 	do {
@@ -257,14 +259,16 @@ static void dequeue_complete_req(void)
 		buf = cpg->p.dst_sg_it.addr;
 		buf = cpg->p.dst_sg_it.addr;
 		buf += cpg->p.dst_start;
 		buf += cpg->p.dst_start;
 
 
-		dst_copy = min(cpg->p.crypt_len, cpg->p.sg_dst_left);
-
-		memcpy(buf, cpg->sram + SRAM_DATA_OUT_START, dst_copy);
+		dst_copy = min(need_copy_len, cpg->p.sg_dst_left);
 
 
+		memcpy(buf,
+		       cpg->sram + SRAM_DATA_OUT_START + sram_offset,
+		       dst_copy);
+		sram_offset += dst_copy;
 		cpg->p.sg_dst_left -= dst_copy;
 		cpg->p.sg_dst_left -= dst_copy;
-		cpg->p.crypt_len -= dst_copy;
+		need_copy_len -= dst_copy;
 		cpg->p.dst_start += dst_copy;
 		cpg->p.dst_start += dst_copy;
-	} while (cpg->p.crypt_len > 0);
+	} while (need_copy_len > 0);
 
 
 	BUG_ON(cpg->eng_st != ENGINE_W_DEQUEUE);
 	BUG_ON(cpg->eng_st != ENGINE_W_DEQUEUE);
 	if (cpg->p.total_req_bytes < req->nbytes) {
 	if (cpg->p.total_req_bytes < req->nbytes) {