Skip to content

Commit a2e0578

Browse files
author
Al Viro
committed
switch copy_module_from_fd() to fdget
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent e95c311 commit a2e0578

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

‎kernel/module.c‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2540,21 +2540,20 @@ static int copy_module_from_user(const void __user *umod, unsigned long len,
25402540
/* Sets info->hdr and info->len. */
25412541
static int copy_module_from_fd(int fd, struct load_info *info)
25422542
{
2543-
struct file *file;
2543+
struct fd f = fdget(fd);
25442544
int err;
25452545
struct kstat stat;
25462546
loff_t pos;
25472547
ssize_t bytes = 0;
25482548

2549-
file = fget(fd);
2550-
if (!file)
2549+
if (!f.file)
25512550
return -ENOEXEC;
25522551

2553-
err = security_kernel_module_from_file(file);
2552+
err = security_kernel_module_from_file(f.file);
25542553
if (err)
25552554
goto out;
25562555

2557-
err = vfs_getattr(&file->f_path, &stat);
2556+
err = vfs_getattr(&f.file->f_path, &stat);
25582557
if (err)
25592558
goto out;
25602559

@@ -2577,7 +2576,7 @@ static int copy_module_from_fd(int fd, struct load_info *info)
25772576

25782577
pos = 0;
25792578
while (pos < stat.size) {
2580-
bytes = kernel_read(file, pos, (char *)(info->hdr) + pos,
2579+
bytes = kernel_read(f.file, pos, (char *)(info->hdr) + pos,
25812580
stat.size - pos);
25822581
if (bytes < 0) {
25832582
vfree(info->hdr);
@@ -2591,7 +2590,7 @@ static int copy_module_from_fd(int fd, struct load_info *info)
25912590
info->len = pos;
25922591

25932592
out:
2594-
fput(file);
2593+
fdput(f);
25952594
return err;
25962595
}
25972596

0 commit comments

Comments
 (0)