[RFC PATCH 3/4] workqueue: remove the unbind workqueue attr sys_file before unregister the workqueue device
From: wanghaibin
Date: Thu Jan 07 2016 - 07:40:58 EST
for workqueue's flag with the WQ_SYSFS | WQ_UNBOUND, the wq_dev will create some sys_files for
unbound attrs, so, remove the unbind workqueue attrs sys_files before unregister the
workqueue device.
Signed-off-by: wanghaibin <wanghaibin.wang@xxxxxxxxxx>
---
kernel/workqueue.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 60e192c..d6527dc 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -5131,10 +5131,13 @@ int workqueue_sysfs_register(struct workqueue_struct *wq)
if (wq->flags & WQ_UNBOUND) {
struct device_attribute *attr;
+ int cnt = 0, i;
- for (attr = wq_sysfs_unbound_attrs; attr->attr.name; attr++) {
+ for (attr = wq_sysfs_unbound_attrs; attr->attr.name; attr++, cnt++) {
ret = device_create_file(&wq_dev->dev, attr);
if (ret) {
+ for (attr = wq_sysfs_unbound_attrs, i = 0; i < cnt; attr++, i++)
+ device_remove_file(&wq_dev->dev, attr);
device_unregister(&wq_dev->dev);
wq->wq_dev = NULL;
return ret;
@@ -5160,6 +5163,11 @@ static void workqueue_sysfs_unregister(struct workqueue_struct *wq)
if (!wq->wq_dev)
return;
+ if (wq->flags & WQ_UNBOUND) {
+ struct device_attribute *attr;
+ for (attr = wq_sysfs_unbound_attrs; attr->attr.name; attr++)
+ device_remove_file(&wq_dev->dev, attr);
+ }
wq->wq_dev = NULL;
device_unregister(&wq_dev->dev);
}
--
1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/