Skip to content

Commit 52441fa

Browse files
sashalevinrustyrussell
authored andcommitted
module: prevent warning when finit_module a 0 sized file
If we try to finit_module on a file sized 0 bytes vmalloc will scream and spit out a warning. Since modules have to be bigger than 0 bytes anyways we can just check that beforehand and avoid the warning. Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Rusty Russell <[email protected]>
1 parent f4953fe commit 52441fa

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

kernel/module.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2527,6 +2527,13 @@ static int copy_module_from_fd(int fd, struct load_info *info)
25272527
err = -EFBIG;
25282528
goto out;
25292529
}
2530+
2531+
/* Don't hand 0 to vmalloc, it whines. */
2532+
if (stat.size == 0) {
2533+
err = -EINVAL;
2534+
goto out;
2535+
}
2536+
25302537
info->hdr = vmalloc(stat.size);
25312538
if (!info->hdr) {
25322539
err = -ENOMEM;

0 commit comments

Comments
 (0)