diff --git a/kernel/module.c b/kernel/module.c index 250092c1d57d6cf582ef801f70a10969e19abab2..41bc1189b0613fd42941b6342c05c857f3ccd035 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -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;