mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Zhen Lei <thunder.leizhen@huawei.com>, Chris Mason <clm@fb.com>,
	Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] btrfs: fix a resource leak in btrfs_init_sysfs()
Date: Sun, 20 Nov 2022 11:11:48 +0800	[thread overview]
Message-ID: <afa7552c-d673-b387-d516-38024f417137@gmx.com> (raw)
In-Reply-To: <a076e281-022f-1f49-b70d-513272ca86cf@gmx.com>



On 2022/11/19 14:53, Qu Wenruo wrote:
> 
> 
> On 2022/11/19 14:43, Zhen Lei wrote:
>> When btrfs_debug_feature_attr_group fails to be created,
>> btrfs_feature_attr_group is not removed.
>>
>> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
> 
> Reviewed-by: Qu Wenruo <wqu@suse.com>

Wait for a minute, should we call sysfs_unmerge_group() first before 
calling sysfs_remove_group()?

As the sysfs_remove_group() will only remove the 
btrfs_feature_attr_group, and kset_unregister() will only free 
btrfs_kset, without removing the added btrfs_static_feature_attr_group.

I haven't yet find a function that will remove all children attrs in 
just one go, or did I miss something?

Thanks,
Qu
> 
> Thanks,
> Qu
>> ---
>>   fs/btrfs/sysfs.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
>> index 699b54b3acaae0b..947125f2ceaaf96 100644
>> --- a/fs/btrfs/sysfs.c
>> +++ b/fs/btrfs/sysfs.c
>> @@ -2322,7 +2322,7 @@ int __init btrfs_init_sysfs(void)
>>   #ifdef CONFIG_BTRFS_DEBUG
>>       ret = sysfs_create_group(&btrfs_kset->kobj, 
>> &btrfs_debug_feature_attr_group);
>>       if (ret)
>> -        goto out2;
>> +        goto out_remove_group;
>>   #endif
>>       return 0;

  reply	other threads:[~2022-11-20  3:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-19  6:43 Zhen Lei
2022-11-19  6:53 ` Qu Wenruo
2022-11-20  3:11   ` Qu Wenruo [this message]
2022-11-20  3:29     ` Qu Wenruo
2022-11-21  3:49       ` Leizhen (ThunderTown)

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=afa7552c-d673-b387-d516-38024f417137@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thunder.leizhen@huawei.com \
    /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®