Whamcloud - gitweb
LU-2053 crypto: Fix cfs_crypto_hash memleak
[fs/lustre-release.git] / libcfs / libcfs / linux / linux-crypto.c
index bacf26a..002b241 100644 (file)
@@ -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);
 
        if (hash_len == NULL) {
                crypto_free_hash(((struct hash_desc *)hdesc)->tfm);
+               cfs_free(hdesc);
                return 0;
        }
        if (hash == NULL || *hash_len < size) {
                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);
                return err;
        }
        crypto_free_hash(((struct hash_desc *)hdesc)->tfm);
+       cfs_free(hdesc);
        return err;
 }
 EXPORT_SYMBOL(cfs_crypto_hash_final);
        return err;
 }
 EXPORT_SYMBOL(cfs_crypto_hash_final);