convert sgx_set_attribute() to fdget()/fdput()
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 14 May 2022 23:40:47 +0000 (19:40 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Fri, 21 Apr 2023 02:55:35 +0000 (22:55 -0400)
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
arch/x86/kernel/cpu/sgx/main.c

index e5a37b6..166692f 100644 (file)
@@ -892,20 +892,19 @@ static struct miscdevice sgx_dev_provision = {
 int sgx_set_attribute(unsigned long *allowed_attributes,
                      unsigned int attribute_fd)
 {
-       struct file *file;
+       struct fd f = fdget(attribute_fd);
 
-       file = fget(attribute_fd);
-       if (!file)
+       if (!f.file)
                return -EINVAL;
 
-       if (file->f_op != &sgx_provision_fops) {
-               fput(file);
+       if (f.file->f_op != &sgx_provision_fops) {
+               fdput(f);
                return -EINVAL;
        }
 
        *allowed_attributes |= SGX_ATTR_PROVISIONKEY;
 
-       fput(file);
+       fdput(f);
        return 0;
 }
 EXPORT_SYMBOL_GPL(sgx_set_attribute);