From: "Rui Qi" <qirui.001@bytedance.com>
To: "Miroslav Benes" <mbenes@suse.cz>
Cc: <jpoimboe@kernel.org>, <jikos@kernel.org>, <pmladek@suse.com>,
<joe.lawrence@redhat.com>, <shuah@kernel.org>,
<live-patching@vger.kernel.org>,
<linux-kselftest@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] selftests/livepatch: fix resource leak in test_klp_syscall init error path
Date: Thu, 4 Jun 2026 16:10:53 +0800 [thread overview]
Message-ID: <070ef555-da56-4695-afe9-e03974113c21@bytedance.com> (raw)
In-Reply-To: <178049217756.69035.11980890855635035855.b4-review@b4>
On 6/3/26 9:09 PM, Miroslav Benes wrote:
> On Tue, 02 Jun 2026 20:45:09 +0800, Rui Qi <qirui.001@bytedance.com> wrote:
>> diff --git a/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c b/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c
>> index 0630ffd9d9a1..d631acae48b9 100644
>> --- a/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c
>> +++ b/tools/testing/selftests/livepatch/test_modules/test_klp_syscall.c
>> @@ -109,7 +109,12 @@ static int livepatch_init(void)
>> */
>> npids = npids_pending;
>>
>> - return klp_enable_patch(&patch);
>> + ret = klp_enable_patch(&patch);
>> + if (ret) {
>> + sysfs_remove_file(klp_kobj, &klp_attr.attr);
>> + kobject_put(klp_kobj);
>> + }
>> + return ret;
>
> Is sysfs_remove_file() needed? I think that kobject_put() should remove
> it automatically since the object is bound to sysfs.
>
You are right, the sysfs_remove_file() call is redundant. When
kobject_put() drops the refcount to zero, kobject_cleanup() is
invoked, which calls __kobject_del() -> sysfs_remove_dir(). The
latter removes the entire kobject directory including all files
created under it via sysfs_create_file(). This is also consistent
with the livepatch_exit() cleanup path, which only calls
kobject_put() without an explicit sysfs_remove_file().
I will send v2 with sysfs_remove_file() removed.
Thank you for the review.
next prev parent reply other threads:[~2026-06-04 8:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-02 12:45 Rui Qi
2026-06-03 13:09 ` Miroslav Benes
2026-06-04 8:10 ` Rui Qi [this message]
2026-06-04 8:32 ` [PATCH v2] " Rui Qi
2026-06-04 8:42 ` sashiko-bot
2026-06-04 13:09 ` Petr Mladek
2026-06-04 13:12 ` Petr Mladek
2026-06-05 6:51 ` Miroslav Benes
2026-06-09 11:04 ` Petr Mladek
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=070ef555-da56-4695-afe9-e03974113c21@bytedance.com \
--to=qirui.001@bytedance.com \
--cc=jikos@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=jpoimboe@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=pmladek@suse.com \
--cc=shuah@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®