Skip to content

Commit

Permalink
crypto: s5p-sss - fix incorrect usage of scatterlists api
Browse files Browse the repository at this point in the history
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: a49e490 ("crypto: s5p-sss - add S5PV210 advanced crypto engine support")
Fixes: 9e4a110 ("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>
  • Loading branch information
Marek Szyprowski authored and Herbert Xu committed Apr 28, 2016
1 parent 6f64389 commit d149797
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/crypto/s5p-sss.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ static int s5p_set_outdata(struct s5p_aes_dev *dev, struct scatterlist *sg)
{
int err;

if (!sg_dma_len(sg)) {
if (!sg->length) {
err = -EINVAL;
goto exit;
}
Expand All @@ -349,7 +349,7 @@ static int s5p_set_indata(struct s5p_aes_dev *dev, struct scatterlist *sg)
{
int err;

if (!sg_dma_len(sg)) {
if (!sg->length) {
err = -EINVAL;
goto exit;
}
Expand Down Expand Up @@ -474,7 +474,7 @@ static void s5p_set_aes(struct s5p_aes_dev *dev,
static bool s5p_is_sg_aligned(struct scatterlist *sg)
{
while (sg) {
if (!IS_ALIGNED(sg_dma_len(sg), AES_BLOCK_SIZE))
if (!IS_ALIGNED(sg->length, AES_BLOCK_SIZE))
return false;
sg = sg_next(sg);
}
Expand Down

0 comments on commit d149797

Please sign in to comment.