crypto: hmac - fix memory leak in hmac_init_tfm()
[linux-2.6-block.git] / crypto / hmac.c
index 241b1868c1d01c5730d919ee598c804e2038de75..ac8c611ee33e407078a0720259a9be0bf26e9f60 100644 (file)
@@ -157,8 +157,10 @@ static int hmac_init_tfm(struct crypto_tfm *tfm)
 
        parent->descsize = sizeof(struct shash_desc) +
                           crypto_shash_descsize(hash);
-       if (WARN_ON(parent->descsize > HASH_MAX_DESCSIZE))
+       if (WARN_ON(parent->descsize > HASH_MAX_DESCSIZE)) {
+               crypto_free_shash(hash);
                return -EINVAL;
+       }
 
        ctx->hash = hash;
        return 0;