memfd: convert memfd_create() to FD_ADD()

Link: https://patch.msgid.link/20251123-work-fd-prepare-v4-25-b6efa1706cfd@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
pull/1354/merge
Christian Brauner 2025-11-23 17:33:43 +01:00
parent 981bec8f69
commit 1afcbbe5d6
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2
1 changed files with 5 additions and 24 deletions

View File

@ -470,9 +470,9 @@ SYSCALL_DEFINE2(memfd_create,
const char __user *, uname,
unsigned int, flags)
{
struct file *file;
int fd, error;
char *name;
char *name __free(kfree) = NULL;
unsigned int fd_flags;
int error;
error = sanitize_flags(&flags);
if (error < 0)
@ -482,25 +482,6 @@ SYSCALL_DEFINE2(memfd_create,
if (IS_ERR(name))
return PTR_ERR(name);
fd = get_unused_fd_flags((flags & MFD_CLOEXEC) ? O_CLOEXEC : 0);
if (fd < 0) {
error = fd;
goto err_free_name;
}
file = alloc_file(name, flags);
if (IS_ERR(file)) {
error = PTR_ERR(file);
goto err_free_fd;
}
fd_install(fd, file);
kfree(name);
return fd;
err_free_fd:
put_unused_fd(fd);
err_free_name:
kfree(name);
return error;
fd_flags = (flags & MFD_CLOEXEC) ? O_CLOEXEC : 0;
return FD_ADD(fd_flags, alloc_file(name, flags));
}