]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ENGR00240112-1 caam: fix user space crypto API support.
authorZhang Jiejing <jiejing.zhang@freescale.com>
Wed, 12 Sep 2012 10:04:49 +0000 (18:04 +0800)
committerOliver Wendt <ow@karo-electronics.de>
Mon, 30 Sep 2013 12:14:06 +0000 (14:14 +0200)
This patch fix the CAAM support for Crypto User Space API support.
in the dma_map_sg_chained() function, the chained mode will loop
until the scatter list end, but when the scatter list end, it will
return null and orignal code will set this to the sg list point
used by dma_sync, so it will panic.

When do chain dma, use a tmp do going through the list.

Signed-off-by Zhang Jiejing <jiejing.zhang@freescale.com>

drivers/crypto/caam/sg_sw_sec4.h

index e05fc58c96377902a0a7fc8bb536dfbc8ff3eebf..f3f5187a14c309e51c5b78e1e1bf4ec0b786bb49 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * CAAM/SEC 4.x functions for using scatterlists in caam driver
  *
- * Copyright (C) 2008-2012 Freescale Semiconductor, Inc.
+ * Copyright (C) 2008-2013 Freescale Semiconductor, Inc.
  *
  */
 
@@ -93,9 +93,13 @@ static int dma_map_sg_chained(struct device *dev, struct scatterlist *sg,
 {
        if (unlikely(chained)) {
                int i;
+               struct scatterlist *tsg = sg;
+               /* Needs a temp copy for sg pointer, otherwise
+                * scatterwalke_sg_next will return null when list is
+                * ended */
                for (i = 0; i < nents; i++) {
-                       dma_map_sg(dev, sg, 1, dir);
-                       sg = scatterwalk_sg_next(sg);
+                       dma_map_sg(dev, tsg, 1, dir);
+                       tsg = scatterwalk_sg_next(tsg);
                }
        } else {
                dma_map_sg(dev, sg, nents, dir);