History

switch copy_module_from_fd() to fdget

Al Viro committed 13 years ago

Commit a2e05781 parent e95c3111 file · +6 −7Browse files

Unified · Split

kernel/module.c+6−7
@@ -2540,21 +2540,20 @@ static int copy_module_from_user(const void __user *umod, unsigned long len, · 2539 unmodified lines
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) · 16 unmodified lines
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) · 7 unmodified lines
25912590 info->len = pos;
25922591
25932592 out:
2594− fput(file);
2593+ fdput(f);
25952594 return err;
25962595 }
25972596