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

Configure Feed

Select the types of activity you want to include in your feed.

crypto: nx - fix bounce buffer leaks in nx842_crypto_{alloc,free}_ctx

The bounce buffers are allocated with __get_free_pages() using
BOUNCE_BUFFER_ORDER (order 2 = 4 pages), but both the allocation error
path and nx842_crypto_free_ctx() release the buffers with free_page().
Use free_pages() with the matching order instead.

Fixes: ed70b479c2c0 ("crypto: nx - add hardware 842 crypto comp alg")
Cc: stable@vger.kernel.org
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Thorsten Blum and committed by
Herbert Xu
adb3faf2 57a13941

+4 -4
+4 -4
drivers/crypto/nx/nx-842.c
··· 116 116 ctx->dbounce = (u8 *)__get_free_pages(GFP_KERNEL, BOUNCE_BUFFER_ORDER); 117 117 if (!ctx->wmem || !ctx->sbounce || !ctx->dbounce) { 118 118 kfree(ctx->wmem); 119 - free_page((unsigned long)ctx->sbounce); 120 - free_page((unsigned long)ctx->dbounce); 119 + free_pages((unsigned long)ctx->sbounce, BOUNCE_BUFFER_ORDER); 120 + free_pages((unsigned long)ctx->dbounce, BOUNCE_BUFFER_ORDER); 121 121 kfree(ctx); 122 122 return ERR_PTR(-ENOMEM); 123 123 } ··· 131 131 struct nx842_crypto_ctx *ctx = p; 132 132 133 133 kfree(ctx->wmem); 134 - free_page((unsigned long)ctx->sbounce); 135 - free_page((unsigned long)ctx->dbounce); 134 + free_pages((unsigned long)ctx->sbounce, BOUNCE_BUFFER_ORDER); 135 + free_pages((unsigned long)ctx->dbounce, BOUNCE_BUFFER_ORDER); 136 136 } 137 137 EXPORT_SYMBOL_GPL(nx842_crypto_free_ctx); 138 138