md: Check for memory allocation failure in faulty personality

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Ingo Molnar <mingo@...>, Neil Brown <neilb@...>
Cc: <linux-raid@...>, <linux-kernel@...>
Date: Wednesday, September 10, 2008 - 3:42 pm

It's a fault injection module, but I don't think we should oops here.

Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
---
 drivers/md/faulty.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Other personalities return -EIO, when something like this happens, but I 
don't see a reason why we shouldn't return the more appropriate -ENOMEM 
here.

diff --git a/drivers/md/faulty.c b/drivers/md/faulty.c
index 268547d..f26c1f9 100644
--- a/drivers/md/faulty.c
+++ b/drivers/md/faulty.c
@@ -287,6 +287,8 @@ static int run(mddev_t *mddev)
 	int i;
 
 	conf_t *conf = kmalloc(sizeof(*conf), GFP_KERNEL);
+	if (!conf)
+		return -ENOMEM;
 
 	for (i=0; i<Modes; i++) {
 		atomic_set(&conf->counters[i], 0);
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
md: Check for memory allocation failure in faulty personality, Sven Wegener, (Wed Sep 10, 3:42 pm)