]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net/kcm: convert kcm_ioctl() to FD_PREPARE()
authorChristian Brauner <brauner@kernel.org>
Sun, 23 Nov 2025 16:33:46 +0000 (17:33 +0100)
committerChristian Brauner <brauner@kernel.org>
Fri, 28 Nov 2025 11:42:34 +0000 (12:42 +0100)
Link: https://patch.msgid.link/20251123-work-fd-prepare-v4-28-b6efa1706cfd@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
net/kcm/kcmsock.c

index b4f01cb075615b782dad953e573233b5e597115c..5dd7e0509a48fc7607b9c0c6a27ec650e7ae93e7 100644 (file)
@@ -1560,24 +1560,16 @@ static int kcm_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
        }
        case SIOCKCMCLONE: {
                struct kcm_clone info;
-               struct file *file;
 
-               info.fd = get_unused_fd_flags(0);
-               if (unlikely(info.fd < 0))
-                       return info.fd;
+               FD_PREPARE(fdf, 0, kcm_clone(sock));
+               if (fdf.err)
+                       return fdf.err;
 
-               file = kcm_clone(sock);
-               if (IS_ERR(file)) {
-                       put_unused_fd(info.fd);
-                       return PTR_ERR(file);
-               }
-               if (copy_to_user((void __user *)arg, &info,
-                                sizeof(info))) {
-                       put_unused_fd(info.fd);
-                       fput(file);
+               info.fd = fd_prepare_fd(fdf);
+               if (copy_to_user((void __user *)arg, &info, sizeof(info)))
                        return -EFAULT;
-               }
-               fd_install(info.fd, file);
+
+               fd_publish(fdf);
                err = 0;
                break;
        }