[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <f90f269d-0a35-4dfa-9684-8e8f2a767734@huawei.com>
Date: Mon, 15 Apr 2024 10:03:50 +0800
From: Hongbo Li <lihongbo22@...wei.com>
To: Kent Overstreet <kent.overstreet@...ux.dev>, Brian Foster
<bfoster@...hat.com>
CC: <linux-bcachefs@...r.kernel.org>, <linux-kernel@...r.kernel.org>, Chao Yu
<chao@...nel.org>
Subject: Re: [PATCH v2] bcachefs: fix error path of __bch2_read_super()
This patch fixes the issue with memory reclamation in certain case. May
be we should use it! 😉
On 2024/4/12 14:53, Hongbo Li wrote:
> Reviewed-by: Hongbo Li <lihongbo22@...wei.com>
>
> On 2024/4/12 14:36, Chao Yu wrote:
>> In __bch2_read_super(), if kstrdup() fails, it needs to release memory
>> in sb->holder, fix to call bch2_free_super() in the error path.
>>
>> Signed-off-by: Chao Yu <chao@...nel.org>
>> ---
>> v2:
>> - add error message in error path pointed out by Hongbo Li.
>> Â fs/bcachefs/super-io.c | 7 +++++--
>> Â 1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c
>> index ad28e370b640..cc80d7d30b8c 100644
>> --- a/fs/bcachefs/super-io.c
>> +++ b/fs/bcachefs/super-io.c
>> @@ -698,8 +698,11 @@ static int __bch2_read_super(const char *path,
>> struct bch_opts *opts,
>> Â Â Â Â Â Â Â Â Â return -ENOMEM;
>> Â Â Â Â Â sb->sb_name = kstrdup(path, GFP_KERNEL);
>> -Â Â Â if (!sb->sb_name)
>> -Â Â Â Â Â Â Â return -ENOMEM;
>> +Â Â Â if (!sb->sb_name) {
>> +Â Â Â Â Â Â Â ret = -ENOMEM;
>> +Â Â Â Â Â Â Â prt_printf(&err, "error allocating memory for sb_name");
>> +Â Â Â Â Â Â Â goto err;
>> +Â Â Â }
>> Â #ifndef __KERNEL__
>> Â Â Â Â Â if (opt_get(*opts, direct_io) == false)
>
Powered by blists - more mailing lists