Commit 52441fa8f2f1ccc9fa97607c6ccf8b46b9fd15ae

Authored by Sasha Levin
Committed by Rusty Russell
1 parent f4953fe6c4

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 <sasha.levin@oracle.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

Showing 1 changed file with 7 additions and 0 deletions Side-by-side Diff

... ... @@ -2527,6 +2527,13 @@
2527 2527 err = -EFBIG;
2528 2528 goto out;
2529 2529 }
  2530 +
  2531 + /* Don't hand 0 to vmalloc, it whines. */
  2532 + if (stat.size == 0) {
  2533 + err = -EINVAL;
  2534 + goto out;
  2535 + }
  2536 +
2530 2537 info->hdr = vmalloc(stat.size);
2531 2538 if (!info->hdr) {
2532 2539 err = -ENOMEM;