From 3e67dee2f6ae7096802a49a16c79fc6adda3a540 Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Wed, 19 Mar 2014 00:07:05 +0100 Subject: [PATCH] staging/xillybus: Handle OOM in xillybus_init() alloc_workqueue() can fail and returns NULL in case of OOM. Handle this case and undo class_create(). Signed-off-by: Richard Weinberger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xillybus/xillybus_core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/staging/xillybus/xillybus_core.c b/drivers/staging/xillybus/xillybus_core.c index 2ebaf166038c..b0a6696f2da0 100644 --- a/drivers/staging/xillybus/xillybus_core.c +++ b/drivers/staging/xillybus/xillybus_core.c @@ -2318,8 +2318,12 @@ static int __init xillybus_init(void) } xillybus_wq = alloc_workqueue(xillyname, 0, 0); + if (!xillybus_wq) { + class_destroy(xillybus_class); + rc = -ENOMEM; + } - return 0; /* Success */ + return rc; } static void __exit xillybus_exit(void) -- 2.20.1