diff --git a/crypto/hmac.c b/crypto/hmac.c
index e37342748f2fa7ff837876f6e59e8aa20820537d..02aa53ea14aae037f66cdf55c25196cce0d12a5c 100644
--- a/crypto/hmac.c
+++ b/crypto/hmac.c
@@ -195,6 +195,7 @@ static int hmac_create(struct crypto_template *tmpl, struct rtattr **tb)
 		goto out_put_alg;
 
 	inst = shash_alloc_instance("hmac", alg);
+	err = PTR_ERR(inst);
 	if (IS_ERR(inst))
 		goto out_put_alg;