Skip to content

Commit

Permalink
crypto: stm32 - fix loop iterating through scatterlist for DMA
Browse files Browse the repository at this point in the history
commit d9c83f71eeceed2cb54bb78be84f2d4055fd9a1f upstream.

We were reading the length of the scatterlist sg after copying value of
tsg inside.
So we are using the size of the previous scatterlist and for the first
one we are using an unitialised value.
Fix this by copying tsg in sg[0] before reading the size.

Fixes : 8a1012d ("crypto: stm32 - Support for STM32 HASH module")
Cc: stable@vger.kernel.org
Signed-off-by: Thomas Bourgoin <thomas.bourgoin@foss.st.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
tbourgoi authored and backslashxx committed Feb 15, 2024
1 parent 1e2bcef commit 3637ca0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/crypto/stm32/stm32-hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,9 @@ static int stm32_hash_dma_send(struct stm32_hash_dev *hdev)
}

for_each_sg(rctx->sg, tsg, rctx->nents, i) {
sg[0] = *tsg;
len = sg->length;

sg[0] = *tsg;
if (sg_is_last(sg)) {
if (hdev->dma_mode == 1) {
len = (ALIGN(sg->length, 16) - 16);
Expand Down

0 comments on commit 3637ca0

Please sign in to comment.