diff --git a/crypto/xcbc.c b/crypto/xcbc.c
index 789cdeee6b7d65a0bac384d66f3e1233aca6880c..e3d9503a034b5774f0000174b7cec9363f50206e 100644
--- a/crypto/xcbc.c
+++ b/crypto/xcbc.c
@@ -307,7 +307,8 @@ static struct crypto_instance *xcbc_alloc(struct rtattr **tb)
 	case 16:
 		break;
 	default:
-		return ERR_PTR(PTR_ERR(alg));
+		inst = ERR_PTR(-EINVAL);
+		goto out_put_alg;
 	}
 
 	inst = crypto_alloc_instance("xcbc", alg);