aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/module.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-08-30 12:41:41 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2013-09-03 23:04:44 -0400
commita2e0578be3652406b2ffd2eeb31cdbdffa325d64 (patch)
treee2e4897fa737c6398c318c99817b44996e85f724 /kernel/module.c
parente95c311e170afc987f87423087f5c7974357f1c8 (diff)
switch copy_module_from_fd() to fdget
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'kernel/module.c')
-rw-r--r--kernel/module.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/kernel/module.c b/kernel/module.c
index 206915830d29..c6756d1c6d73 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2540,21 +2540,20 @@ static int copy_module_from_user(const void __user *umod, unsigned long len,
2540/* Sets info->hdr and info->len. */ 2540/* Sets info->hdr and info->len. */
2541static int copy_module_from_fd(int fd, struct load_info *info) 2541static int copy_module_from_fd(int fd, struct load_info *info)
2542{ 2542{
2543 struct file *file; 2543 struct fd f = fdget(fd);
2544 int err; 2544 int err;
2545 struct kstat stat; 2545 struct kstat stat;
2546 loff_t pos; 2546 loff_t pos;
2547 ssize_t bytes = 0; 2547 ssize_t bytes = 0;
2548 2548
2549 file = fget(fd); 2549 if (!f.file)
2550 if (!file)
2551 return -ENOEXEC; 2550 return -ENOEXEC;
2552 2551
2553 err = security_kernel_module_from_file(file); 2552 err = security_kernel_module_from_file(f.file);
2554 if (err) 2553 if (err)
2555 goto out; 2554 goto out;
2556 2555
2557 err = vfs_getattr(&file->f_path, &stat); 2556 err = vfs_getattr(&f.file->f_path, &stat);
2558 if (err) 2557 if (err)
2559 goto out; 2558 goto out;
2560 2559
@@ -2577,7 +2576,7 @@ static int copy_module_from_fd(int fd, struct load_info *info)
2577 2576
2578 pos = 0; 2577 pos = 0;
2579 while (pos < stat.size) { 2578 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,
2581 stat.size - pos); 2580 stat.size - pos);
2582 if (bytes < 0) { 2581 if (bytes < 0) {
2583 vfree(info->hdr); 2582 vfree(info->hdr);
@@ -2591,7 +2590,7 @@ static int copy_module_from_fd(int fd, struct load_info *info)
2591 info->len = pos; 2590 info->len = pos;
2592 2591
2593out: 2592out:
2594 fput(file); 2593 fdput(f);
2595 return err; 2594 return err;
2596} 2595}
2597 2596