summaryrefslogtreecommitdiff
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)
downloadlwn-a2e0578be3652406b2ffd2eeb31cdbdffa325d64.tar.gz
lwn-a2e0578be3652406b2ffd2eeb31cdbdffa325d64.zip
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,
/* Sets info->hdr and info->len. */
static int copy_module_from_fd(int fd, struct load_info *info)
{
- struct file *file;
+ struct fd f = fdget(fd);
int err;
struct kstat stat;
loff_t pos;
ssize_t bytes = 0;
- file = fget(fd);
- if (!file)
+ if (!f.file)
return -ENOEXEC;
- err = security_kernel_module_from_file(file);
+ err = security_kernel_module_from_file(f.file);
if (err)
goto out;
- err = vfs_getattr(&file->f_path, &stat);
+ err = vfs_getattr(&f.file->f_path, &stat);
if (err)
goto out;
@@ -2577,7 +2576,7 @@ static int copy_module_from_fd(int fd, struct load_info *info)
pos = 0;
while (pos < stat.size) {
- bytes = kernel_read(file, pos, (char *)(info->hdr) + pos,
+ bytes = kernel_read(f.file, pos, (char *)(info->hdr) + pos,
stat.size - pos);
if (bytes < 0) {
vfree(info->hdr);
@@ -2591,7 +2590,7 @@ static int copy_module_from_fd(int fd, struct load_info *info)
info->len = pos;
out:
- fput(file);
+ fdput(f);
return err;
}