From: Oleg Drokin Date: Sat, 29 Sep 2012 20:15:40 +0000 (-0400) Subject: LU-2053 crypto: Fix cfs_crypto_hash memleak X-Git-Tag: 2.3.52~27 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=1d7fa63a7f78aeed42e4e3b6709131e92aad1b30;hp=fd82b671957cbddc47b8d28117ed3c90b0521d19 LU-2053 crypto: Fix cfs_crypto_hash memleak Commit 353e3c2f8d9f195c0f87a16259f22b2f84de11d4 that introduced cryptoapi support to Lustre is allocating a hdesc in cfs_crypto_hash_init and never freeing it. This function is called every time a checksum needs to be calculated, so on every bulk RPC send or receive, so even though allocations are small, they tend to still quickly consume all available memory with any significant amount of IO. Change-Id: Ic654c6102ea4306a81c1f7592c81cfb6e597f1f2 Signed-off-by: Oleg Drokin Reviewed-on: http://review.whamcloud.com/4135 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Alexander Boyko --- diff --git a/libcfs/libcfs/linux/linux-crypto.c b/libcfs/libcfs/linux/linux-crypto.c index bacf26a..002b241 100644 --- a/libcfs/libcfs/linux/linux-crypto.c +++ b/libcfs/libcfs/linux/linux-crypto.c @@ -249,6 +249,7 @@ int cfs_crypto_hash_final(struct cfs_crypto_hash_desc *hdesc, if (hash_len == NULL) { crypto_free_hash(((struct hash_desc *)hdesc)->tfm); + cfs_free(hdesc); return 0; } if (hash == NULL || *hash_len < size) { @@ -262,6 +263,7 @@ int cfs_crypto_hash_final(struct cfs_crypto_hash_desc *hdesc, return err; } crypto_free_hash(((struct hash_desc *)hdesc)->tfm); + cfs_free(hdesc); return err; } EXPORT_SYMBOL(cfs_crypto_hash_final);