summaryrefslogtreecommitdiff
path: root/kernel/module
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2024-07-20 01:17:52 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2024-11-03 01:28:06 -0500
commit05e555642c4613d5a2438351c705bb2119352757 (patch)
treed33b0f332362330e060b438b04711ca44ff96cfa /kernel/module
parent53c0a58beb60b76e105a61aae518fd780eec03d9 (diff)
regularize emptiness checks in fini_module(2) and vfs_dedupe_file_range()
With few exceptions emptiness checks are done as fd_file(...) in boolean context (usually something like if (!fd_file(f))...); those will be taken care of later. However, there's a couple of places where we do those checks as 'store fd_file(...) into a variable, then check if this variable is NULL' and those are harder to spot. Get rid of those now. use fd_empty() instead of extracting file and then checking it for NULL. Reviewed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'kernel/module')
-rw-r--r--kernel/module/main.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/kernel/module/main.c b/kernel/module/main.c
index 49b9bca9de12..d785973d8a51 100644
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -3202,7 +3202,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;
/* Are we the winners of the race and get to do this? */
@@ -3234,6 +3234,8 @@ SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags)
return -EINVAL;
f = fdget(fd);
+ if (fd_empty(f))
+ return -EBADF;
err = idempotent_init_module(fd_file(f), uargs, flags);
fdput(f);
return err;