From: Chen Gang <gang.chen@asianux.com>
To: Tejun Heo <tj@kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH] kernel/workqueue.c: need call device_remove_file() when failure occurs after called device_create_file()
Date: Wed, 15 May 2013 14:13:14 +0800 [thread overview]
Message-ID: <5193277A.3040506@asianux.com> (raw)
In-Reply-To: <5192EFE0.4040903@asianux.com>
In workqueue_sysfs_register(), when failure occurs after called
device_create_file(), need call device_remove_file() to release the
related resources, then call device_unregister().
Or it will cause issue.
For individual 'device_attributs' (just like our case), need call
device_remove_file() explictly and then call device_unregister(),
please reference drivers/base/*.c (e.g node.c or cpu.c).
Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
kernel/workqueue.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 1ae6028..de11dae 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -3323,6 +3323,8 @@ int workqueue_sysfs_register(struct workqueue_struct *wq)
for (attr = wq_sysfs_unbound_attrs; attr->attr.name; attr++) {
ret = device_create_file(&wq_dev->dev, attr);
if (ret) {
+ while (--attr >= wq_sysfs_unbound_attrs)
+ device_remove_file(&wq_dev->dev, attr);
device_unregister(&wq_dev->dev);
wq->wq_dev = NULL;
return ret;
--
1.7.7.6
next prev parent reply other threads:[~2013-05-15 6:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-14 12:25 [PATCH] kernel/workqueue.c: better to free related resources when failure occurs in wq_numa_init() Chen Gang
2013-05-14 15:17 ` Tejun Heo
2013-05-15 2:16 ` Chen Gang
2013-05-15 6:13 ` Chen Gang [this message]
2013-05-15 21:22 ` [PATCH] kernel/workqueue.c: need call device_remove_file() when failure occurs after called device_create_file() Tejun Heo
2013-05-16 3:33 ` Chen Gang
2013-05-16 4:16 ` Chen Gang
2013-05-16 4:48 ` Chen Gang
2013-05-16 17:50 ` Tejun Heo
2013-05-17 2:51 ` Chen Gang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5193277A.3040506@asianux.com \
--to=gang.chen@asianux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox