Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+7 -15
+7 -15
net/kcm/kcmsock.c
··· 1560 1560 } 1561 1561 case SIOCKCMCLONE: { 1562 1562 struct kcm_clone info; 1563 - struct file *file; 1564 1563 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; 1568 1567 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))) 1578 1570 return -EFAULT; 1579 - } 1580 - fd_install(info.fd, file); 1571 + 1572 + fd_publish(fdf); 1581 1573 err = 0; 1582 1574 break; 1583 1575 }