Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

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 <m.szyprowski@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Acked-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Marek Szyprowski and committed by
Herbert Xu
d1497977 6f643897

+3 -3
+3 -3
drivers/crypto/s5p-sss.c
··· 327 327 { 328 328 int err; 329 329 330 - if (!sg_dma_len(sg)) { 330 + if (!sg->length) { 331 331 err = -EINVAL; 332 332 goto exit; 333 333 } ··· 349 349 { 350 350 int err; 351 351 352 - if (!sg_dma_len(sg)) { 352 + if (!sg->length) { 353 353 err = -EINVAL; 354 354 goto exit; 355 355 } ··· 474 474 static bool s5p_is_sg_aligned(struct scatterlist *sg) 475 475 { 476 476 while (sg) { 477 - if (!IS_ALIGNED(sg_dma_len(sg), AES_BLOCK_SIZE)) 477 + if (!IS_ALIGNED(sg->length, AES_BLOCK_SIZE)) 478 478 return false; 479 479 sg = sg_next(sg); 480 480 }