提交 52441fa8 编写于 作者: S Sasha Levin 提交者: Rusty Russell

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: NSasha Levin <sasha.levin@oracle.com>
Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
上级 f4953fe6
...@@ -2527,6 +2527,13 @@ static int copy_module_from_fd(int fd, struct load_info *info) ...@@ -2527,6 +2527,13 @@ static int copy_module_from_fd(int fd, struct load_info *info)
err = -EFBIG; err = -EFBIG;
goto out; goto out;
} }
/* Don't hand 0 to vmalloc, it whines. */
if (stat.size == 0) {
err = -EINVAL;
goto out;
}
info->hdr = vmalloc(stat.size); info->hdr = vmalloc(stat.size);
if (!info->hdr) { if (!info->hdr) {
err = -ENOMEM; err = -ENOMEM;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册