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 context leak in nx842_crypto_free_ctx

Since the scomp conversion, nx842_crypto_alloc_ctx() allocates the
context separately, but nx842_crypto_free_ctx() never releases it. Add
the missing kfree(ctx) to nx842_crypto_free_ctx(), and reuse
nx842_crypto_free_ctx() in the allocation error path.

Fixes: 980b5705f4e7 ("crypto: nx - Migrate to scomp API")
Cc: stable@vger.kernel.org
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Thorsten Blum and committed by
Herbert Xu
344e6a4f adb3faf2

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