diff --git a/mm/memfd.c b/mm/memfd.c
index 08f5f8304746fb675f744ed93eaa7eaf7e53a6d6..b0104b49bf82c0d3ee83a85dbafdb9dac280eec0 100644
--- a/mm/memfd.c
+++ b/mm/memfd.c
@@ -328,7 +328,8 @@ SYSCALL_DEFINE2(memfd_create,
 
 	if (flags & MFD_ALLOW_SEALING) {
 		file_seals = memfd_file_seals_ptr(file);
-		*file_seals &= ~F_SEAL_SEAL;
+		if (file_seals)
+			*file_seals &= ~F_SEAL_SEAL;
 	}
 
 	fd_install(fd, file);