From: Liu Shixin <liushixin2@huawei.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, Liu Shixin <liushixin2@huawei.com>
Subject: [PATCH] kobject: hide illegible sysfs warning of kobject_del()
Date: Fri, 11 Nov 2022 14:58:07 +0800 [thread overview]
Message-ID: <20221111065807.3278713-1-liushixin2@huawei.com> (raw)
Some consumers do not care whether kobject_add() succeed or failed such as
irqdesc. They call kobject_del() all the time even if kobject_add() failed.
Then kernel will report some illegible sysfs warning like this:
kernfs: can not remove 'actions', no directory
WARNING: CPU: 0 PID: 277 at fs/kernfs/dir.c:1615 kernfs_remove_by_name_ns+0xd5/0xe0
[...]
Call Trace:
<TASK>
remove_files.isra.0+0x3f/0xb0
sysfs_remove_group+0x68/0xe0
sysfs_remove_groups+0x41/0x70
__kobject_del+0x45/0xc0
kobject_del+0x2a/0x40
free_desc+0x44/0x70
irq_free_descs+0x5d/0x90
[...]
Check whether kobject is added successfully by using kobj->state_in_sysfs
in kobject_del() and skip deleting it if not added at all.
Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
lib/kobject.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/kobject.c b/lib/kobject.c
index a0b2dbfcfa23..f6163a3a41c2 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -604,7 +604,7 @@ void kobject_del(struct kobject *kobj)
{
struct kobject *parent;
- if (!kobj)
+ if (!kobj || !kobj->state_in_sysfs)
return;
parent = kobj->parent;
--
2.25.1
next reply other threads:[~2022-11-11 6:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-11 6:58 Liu Shixin [this message]
2022-11-11 6:26 ` Greg Kroah-Hartman
2022-11-11 8:27 ` Liu Shixin
2022-11-11 9:11 ` Greg Kroah-Hartman
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=20221111065807.3278713-1-liushixin2@huawei.com \
--to=liushixin2@huawei.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@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
all inboxes | Powered by JetHome®