diff --git a/crypto/cmac.c b/crypto/cmac.c
index 7a8bfbd548f60835fbf417ab96e43b749a5d283f..b6c4059764aa7330ac44a2809759247375959154 100644
--- a/crypto/cmac.c
+++ b/crypto/cmac.c
@@ -243,6 +243,7 @@ static int cmac_create(struct crypto_template *tmpl, struct rtattr **tb)
 	case 8:
 		break;
 	default:
+		err = -EINVAL;
 		goto out_put_alg;
 	}