Skip to content

Commit 910bb34

Browse files
tobluxgregkh
authored andcommitted
crypto: nx - fix bounce buffer leaks in nx842_crypto_{alloc,free}_ctx
[ Upstream commit adb3faf ] 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: ed70b47 ("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> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 041acda commit 910bb34

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/crypto/nx/nx-842.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ int nx842_crypto_init(struct crypto_tfm *tfm, struct nx842_driver *driver)
112112
ctx->dbounce = (u8 *)__get_free_pages(GFP_KERNEL, BOUNCE_BUFFER_ORDER);
113113
if (!ctx->wmem || !ctx->sbounce || !ctx->dbounce) {
114114
kfree(ctx->wmem);
115-
free_page((unsigned long)ctx->sbounce);
116-
free_page((unsigned long)ctx->dbounce);
115+
free_pages((unsigned long)ctx->sbounce, BOUNCE_BUFFER_ORDER);
116+
free_pages((unsigned long)ctx->dbounce, BOUNCE_BUFFER_ORDER);
117117
return -ENOMEM;
118118
}
119119

@@ -126,8 +126,8 @@ void nx842_crypto_exit(struct crypto_tfm *tfm)
126126
struct nx842_crypto_ctx *ctx = crypto_tfm_ctx(tfm);
127127

128128
kfree(ctx->wmem);
129-
free_page((unsigned long)ctx->sbounce);
130-
free_page((unsigned long)ctx->dbounce);
129+
free_pages((unsigned long)ctx->sbounce, BOUNCE_BUFFER_ORDER);
130+
free_pages((unsigned long)ctx->dbounce, BOUNCE_BUFFER_ORDER);
131131
}
132132
EXPORT_SYMBOL_GPL(nx842_crypto_exit);
133133

0 commit comments

Comments
 (0)