linux/drivers/crypto/marvell
Boris BREZILLON 7850c91b17 crypto: marvell/cesa - fix memory leak
Crypto requests are not guaranteed to be finalized (->final() call),
and can be freed at any moment, without getting any notification from
the core. This can lead to memory leaks of the ->cache buffer.

Make this buffer part of the request object, and allocate an extra buffer
from the DMA cache pool when doing DMA operations.

As a side effect, this patch also fixes another bug related to cache
allocation and DMA operations. When the core allocates a new request and
import an existing state, a cache buffer can be allocated (depending
on the state). The problem is, at that very moment, we don't know yet
whether the request will use DMA or not, and since everything is
likely to be initialized to zero, mv_cesa_ahash_alloc_cache() thinks it
should allocate a buffer for standard operation. But when
mv_cesa_ahash_free_cache() is called, req->type has been set to
CESA_DMA_REQ in the meantime, thus leading to an invalind dma_pool_free()
call (the buffer passed in argument has not been allocated from the pool).

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Reported-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2016-03-17 19:09:04 +08:00
..
cesa.c crypto: marvell/cesa - Drop owner assignment from platform_driver 2015-07-14 14:56:48 +08:00
cesa.h crypto: marvell/cesa - fix memory leak 2016-03-17 19:09:04 +08:00
cipher.c crypto: marvell - check return value of sg_nents_for_len 2015-11-17 22:00:35 +08:00
hash.c crypto: marvell/cesa - fix memory leak 2016-03-17 19:09:04 +08:00
Makefile
tdma.c crypto: marvell/cesa - use __le32 for hardware descriptors 2015-10-20 22:13:58 +08:00