[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <519236E0.4020301@asianux.com>
Date: Tue, 14 May 2013 21:06:40 +0800
From: Chen Gang <gang.chen@...anux.com>
To: tj@...nel.org
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH] kernel/workqueue.c: kfree issue, need check flag 'WQ_UNBOUND'
when processing failure.
When failure occurs in __alloc_workqueue_key(), if 'flags' has
'WQ_UNBOUND', the destroy_workqueue() will not release 'wq'.
In this situation, we need release it, or will cause memory leak.
And also simplify the related code.
Signed-off-by: Chen Gang <gang.chen@...anux.com>
---
kernel/workqueue.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 1ae6028..bf644d4 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -4167,12 +4167,13 @@ struct workqueue_struct *__alloc_workqueue_key(const char *fmt,
return wq;
-err_free_wq:
- free_workqueue_attrs(wq->unbound_attrs);
- kfree(wq);
- return NULL;
err_destroy:
destroy_workqueue(wq);
+ if (flags & WQ_UNBOUND) {
+err_free_wq:
+ free_workqueue_attrs(wq->unbound_attrs);
+ kfree(wq);
+ }
return NULL;
}
EXPORT_SYMBOL_GPL(__alloc_workqueue_key);
--
1.7.7.6
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists