Slightly unidiomatic emptiness check; just lift it out of idempotent_init_module() and into finit_module(2) and that's it. Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx> --- kernel/module/main.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/kernel/module/main.c b/kernel/module/main.c index 98fda13fdca7..f2f045b3740d 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -3177,7 +3177,7 @@ static int idempotent_init_module(struct file *f, const char __user * uargs, int { struct idempotent idem; - if (!f || !(f->f_mode & FMODE_READ)) + if (!(f->f_mode & FMODE_READ)) return -EBADF; /* See if somebody else is doing the operation? */ @@ -3193,10 +3193,7 @@ static int idempotent_init_module(struct file *f, const char __user * uargs, int SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags) { - int err; - struct fd f; - - err = may_init_module(); + int err = may_init_module(); if (err) return err; @@ -3207,10 +3204,10 @@ SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags) |MODULE_INIT_COMPRESSED_FILE)) return -EINVAL; - f = fdget(fd); - err = idempotent_init_module(fd_file(f), uargs, flags); - fdput(f); - return err; + CLASS(fd, f)(fd); + if (fd_empty(f)) + return -EBADF; + return idempotent_init_module(fd_file(f), uargs, flags); } /* Keep in sync with MODULE_FLAGS_BUF_SIZE !!! */ -- 2.39.2