Skip to content

Commit 0d52d06

Browse files
committed
net/kcm: convert kcm_ioctl() to FD_PREPARE()
Link: https://patch.msgid.link/20251123-work-fd-prepare-v4-28-b6efa1706cfd@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent fe67b06 commit 0d52d06

1 file changed

Lines changed: 7 additions & 15 deletions

File tree

net/kcm/kcmsock.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,24 +1560,16 @@ static int kcm_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
15601560
}
15611561
case SIOCKCMCLONE: {
15621562
struct kcm_clone info;
1563-
struct file *file;
15641563

1565-
info.fd = get_unused_fd_flags(0);
1566-
if (unlikely(info.fd < 0))
1567-
return info.fd;
1564+
FD_PREPARE(fdf, 0, kcm_clone(sock));
1565+
if (fdf.err)
1566+
return fdf.err;
15681567

1569-
file = kcm_clone(sock);
1570-
if (IS_ERR(file)) {
1571-
put_unused_fd(info.fd);
1572-
return PTR_ERR(file);
1573-
}
1574-
if (copy_to_user((void __user *)arg, &info,
1575-
sizeof(info))) {
1576-
put_unused_fd(info.fd);
1577-
fput(file);
1568+
info.fd = fd_prepare_fd(fdf);
1569+
if (copy_to_user((void __user *)arg, &info, sizeof(info)))
15781570
return -EFAULT;
1579-
}
1580-
fd_install(info.fd, file);
1571+
1572+
fd_publish(fdf);
15811573
err = 0;
15821574
break;
15831575
}

0 commit comments

Comments
 (0)