From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753325AbcAGMkz (ORCPT ); Thu, 7 Jan 2016 07:40:55 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:20323 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753205AbcAGMks (ORCPT ); Thu, 7 Jan 2016 07:40:48 -0500 From: wanghaibin To: CC: , , , wanghaibin Subject: [RFC PATCH 3/4] workqueue: remove the unbind workqueue attr sys_file before unregister the workqueue device Date: Thu, 7 Jan 2016 20:38:58 +0800 Message-ID: <1452170339-26748-4-git-send-email-wanghaibin.wang@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1452170339-26748-1-git-send-email-wanghaibin.wang@huawei.com> References: <1452170339-26748-1-git-send-email-wanghaibin.wang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.177.27.144] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090205.568E5CCD.00CF,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 3a0c72147e27208d5fca92b46289a51d Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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