[PATCH 4.17 45/45] crypto: omap-sham - fix memleak
From: Greg Kroah-Hartman
Date: Thu Jun 14 2018 - 10:07:21 EST
4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bin Liu <b-liu@xxxxxx>
commit 9dbc8a0328efa485a6f5b68b867f9f523a3fbeff upstream.
Fixes: 8043bb1ae03cb ("crypto: omap-sham - convert driver logic to use sgs for data xmit")
The memory pages freed in omap_sham_finish_req() were less than those
allocated in omap_sham_copy_sgs().
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Bin Liu <b-liu@xxxxxx>
Acked-by: Tero Kristo <t-kristo@xxxxxx>
Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
drivers/crypto/omap-sham.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/drivers/crypto/omap-sham.c
+++ b/drivers/crypto/omap-sham.c
@@ -1087,7 +1087,7 @@ static void omap_sham_finish_req(struct
if (test_bit(FLAGS_SGS_COPIED, &dd->flags))
free_pages((unsigned long)sg_virt(ctx->sg),
- get_order(ctx->sg->length));
+ get_order(ctx->sg->length + ctx->bufcnt));
if (test_bit(FLAGS_SGS_ALLOCED, &dd->flags))
kfree(ctx->sg);