]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
hv: convert mshv_ioctl_create_partition() to FD_ADD()
authorChristian Brauner <brauner@kernel.org>
Sun, 23 Nov 2025 16:33:57 +0000 (17:33 +0100)
committerChristian Brauner <brauner@kernel.org>
Fri, 28 Nov 2025 11:42:35 +0000 (12:42 +0100)
Link: https://patch.msgid.link/20251123-work-fd-prepare-v4-39-b6efa1706cfd@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
drivers/hv/mshv_root_main.c

index e3b2bd417c46405f27159080f7411035915697fc..bed1a02425cd399ef8dfb0350a39c84fe5ff5079 100644 (file)
@@ -1870,8 +1870,6 @@ mshv_ioctl_create_partition(void __user *user_arg, struct device *module_dev)
        struct hv_partition_creation_properties creation_properties = {};
        union hv_partition_isolation_properties isolation_properties = {};
        struct mshv_partition *partition;
-       struct file *file;
-       int fd;
        long ret;
 
        if (copy_from_user(&args, user_arg, sizeof(args)))
@@ -1938,29 +1936,13 @@ mshv_ioctl_create_partition(void __user *user_arg, struct device *module_dev)
                goto delete_partition;
 
        ret = mshv_init_async_handler(partition);
-       if (ret)
-               goto remove_partition;
-
-       fd = get_unused_fd_flags(O_CLOEXEC);
-       if (fd < 0) {
-               ret = fd;
-               goto remove_partition;
-       }
-
-       file = anon_inode_getfile("mshv_partition", &mshv_partition_fops,
-                                 partition, O_RDWR);
-       if (IS_ERR(file)) {
-               ret = PTR_ERR(file);
-               goto put_fd;
+       if (!ret) {
+               ret = FD_ADD(O_CLOEXEC, anon_inode_getfile("mshv_partition",
+                                                          &mshv_partition_fops,
+                                                          partition, O_RDWR));
+               if (ret >= 0)
+                       return ret;
        }
-
-       fd_install(fd, file);
-
-       return fd;
-
-put_fd:
-       put_unused_fd(fd);
-remove_partition:
        remove_partition(partition);
 delete_partition:
        hv_call_delete_partition(partition->pt_id);