Commit 4a223a2d authored by Marek Szyprowski's avatar Marek Szyprowski Committed by Ben Hutchings

crypto: s5p-sss - fix incorrect usage of scatterlists api

commit d1497977 upstream.

sg_dma_len() macro can be used only on scattelists which are mapped, so
all calls to it before dma_map_sg() are invalid. Replace them by proper
check for direct sg segment length read.

Fixes: a49e490c ("crypto: s5p-sss - add S5PV210 advanced crypto engine support")
Fixes: 9e4a1100 ("crypto: s5p-sss - Handle unaligned buffers")
Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: default avatarKrzysztof Kozlowski <k.kozlowski@samsung.com>
Acked-by: default avatarVladimir Zapolskiy <vz@mleia.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
[bwh: Backported to 3.2: unaligned DMA is unsupported so there is a different
 set of calls to replace]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 5dd415ec
...@@ -210,11 +210,11 @@ static int s5p_set_outdata(struct s5p_aes_dev *dev, struct scatterlist *sg) ...@@ -210,11 +210,11 @@ static int s5p_set_outdata(struct s5p_aes_dev *dev, struct scatterlist *sg)
{ {
int err; int err;
if (!IS_ALIGNED(sg_dma_len(sg), AES_BLOCK_SIZE)) { if (!IS_ALIGNED(sg->length, AES_BLOCK_SIZE)) {
err = -EINVAL; err = -EINVAL;
goto exit; goto exit;
} }
if (!sg_dma_len(sg)) { if (!sg->length) {
err = -EINVAL; err = -EINVAL;
goto exit; goto exit;
} }
...@@ -236,11 +236,11 @@ static int s5p_set_indata(struct s5p_aes_dev *dev, struct scatterlist *sg) ...@@ -236,11 +236,11 @@ static int s5p_set_indata(struct s5p_aes_dev *dev, struct scatterlist *sg)
{ {
int err; int err;
if (!IS_ALIGNED(sg_dma_len(sg), AES_BLOCK_SIZE)) { if (!IS_ALIGNED(sg->length, AES_BLOCK_SIZE)) {
err = -EINVAL; err = -EINVAL;
goto exit; goto exit;
} }
if (!sg_dma_len(sg)) { if (!sg->length) {
err = -EINVAL; err = -EINVAL;
goto exit; goto exit;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment