lkml.org 
[lkml]   [2016]   [Jan]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 3/4] workqueue: remove the unbind workqueue attr sys_file before unregister the workqueue device
Date
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@huawei.com>
---
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



\
 
 \ /
  Last update: 2016-01-07 14:21    [W:0.140 / U:0.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site