From 4a223a2dd4e405a1c1022e7a6787fdc5239ad7e5 Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Tue, 26 Apr 2016 09:29:26 +0200 Subject: [PATCH] crypto: s5p-sss - fix incorrect usage of scatterlists api commit d1497977fecb9acce05988d6322ad415ef93bb39 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: a49e490c7a8a ("crypto: s5p-sss - add S5PV210 advanced crypto engine support") Fixes: 9e4a1100a445 ("crypto: s5p-sss - Handle unaligned buffers") Signed-off-by: Marek Szyprowski Reviewed-by: Krzysztof Kozlowski Acked-by: Vladimir Zapolskiy Signed-off-by: Herbert Xu [bwh: Backported to 3.2: unaligned DMA is unsupported so there is a different set of calls to replace] Signed-off-by: Ben Hutchings --- drivers/crypto/s5p-sss.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c index 78826a6b7ed1..4f30887461ae 100644 --- a/drivers/crypto/s5p-sss.c +++ b/drivers/crypto/s5p-sss.c @@ -210,11 +210,11 @@ static int s5p_set_outdata(struct s5p_aes_dev *dev, struct scatterlist *sg) { int err; - if (!IS_ALIGNED(sg_dma_len(sg), AES_BLOCK_SIZE)) { + if (!IS_ALIGNED(sg->length, AES_BLOCK_SIZE)) { err = -EINVAL; goto exit; } - if (!sg_dma_len(sg)) { + if (!sg->length) { err = -EINVAL; goto exit; } @@ -236,11 +236,11 @@ static int s5p_set_indata(struct s5p_aes_dev *dev, struct scatterlist *sg) { int err; - if (!IS_ALIGNED(sg_dma_len(sg), AES_BLOCK_SIZE)) { + if (!IS_ALIGNED(sg->length, AES_BLOCK_SIZE)) { err = -EINVAL; goto exit; } - if (!sg_dma_len(sg)) { + if (!sg->length) { err = -EINVAL; goto exit; } -- 2.39.2