]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
crypto: omap - Allocate OMAP_CRYPTO_FORCE_COPY scatterlists correctly
authorKees Cook <kees@kernel.org>
Sat, 7 Feb 2026 03:49:54 +0000 (19:49 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 10 Feb 2026 16:43:21 +0000 (08:43 -0800)
The existing allocation of scatterlists in omap_crypto_copy_sg_lists()
was allocating an array of scatterlist pointers, not scatterlist objects,
resulting in a 4x too small allocation.

Use sizeof(*new_sg) to get the correct object size.

Fixes: 74ed87e7e7f7 ("crypto: omap - add base support library for common routines")
Signed-off-by: Kees Cook <kees@kernel.org>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/crypto/omap-crypto.c

index a4cc6bf146ec09524c4d43412b7050f042649aff..0345c9383d50973f215c657ea99c2717e0a8b70c 100644 (file)
@@ -21,7 +21,7 @@ static int omap_crypto_copy_sg_lists(int total, int bs,
        struct scatterlist *tmp;
 
        if (!(flags & OMAP_CRYPTO_FORCE_SINGLE_ENTRY)) {
-               new_sg = kmalloc_array(n, sizeof(*sg), GFP_KERNEL);
+               new_sg = kmalloc_array(n, sizeof(*new_sg), GFP_KERNEL);
                if (!new_sg)
                        return -ENOMEM;