convert sgx_set_attribute() to fdget()/fdput()

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2022-05-14 19:40:47 -04:00
parent 281117ccb2
commit e73d43760a

View 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);