diff
--- a/key_instantiate_and_link.c
+++ b/key_instantiate_and_link.c
@@ -41,5 +41,9 @@
 		ret = key->type->instantiate(key, prep);
 		if (ret == 0) {
 
+			if (prep->expiry > MAX_EXPIRY_VALUE) {
+				ret = -EINVAL; // Invalid argument
+				goto error;
+			}
 			key_set_expiry(key, prep->expiry);
 error:

