Skip to content

Commit

Permalink
module: prevent warning when finit_module a 0 sized file
Browse files Browse the repository at this point in the history
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 <sasha.levin@oracle.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
Sasha Levin authored and Rusty Russell committed Jan 3, 2013
1 parent f4953fe commit 52441fa
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -2527,6 +2527,13 @@ static int copy_module_from_fd(int fd, struct load_info *info)
err = -EFBIG;
goto out;
}

/* Don't hand 0 to vmalloc, it whines. */
if (stat.size == 0) {
err = -EINVAL;
goto out;
}

info->hdr = vmalloc(stat.size);
if (!info->hdr) {
err = -ENOMEM;
Expand Down

0 comments on commit 52441fa

Please sign in to comment.