public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] module: prevent warning when finit_module a 0 sized file
@ 2012-12-28 19:27 Sasha Levin
  2013-01-03  0:41 ` Rusty Russell
  0 siblings, 1 reply; 4+ messages in thread
From: Sasha Levin @ 2012-12-28 19:27 UTC (permalink / raw)
  To: Rusty Russell, linux-kernel; +Cc: Sasha Levin

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>
---
 kernel/module.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kernel/module.c b/kernel/module.c
index 250092c..2e1ce2e 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2527,6 +2527,12 @@ static int copy_module_from_fd(int fd, struct load_info *info)
 		err = -EFBIG;
 		goto out;
 	}
+
+	if (stat.size == 0) {
+		err = -EINVAL;
+		goto out;
+	}
+
 	info->hdr = vmalloc(stat.size);
 	if (!info->hdr) {
 		err = -ENOMEM;
-- 
1.8.0.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-01-07  1:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-28 19:27 [PATCH] module: prevent warning when finit_module a 0 sized file Sasha Levin
2013-01-03  0:41 ` Rusty Russell
2013-01-03 22:14   ` Sasha Levin
2013-01-07  0:50     ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox