From: Wu Guanghao <wuguanghao3@huawei.com>
To: "Благодаренко Артём" <artem.blagodarenko@gmail.com>
Cc: <linux-ext4@vger.kernel.org>, <liuzhiqiang26@huawei.com>,
<linfeilong@huawei.com>
Subject: Re: [PATCH 03/12] zap_sector: fix memory leak
Date: Tue, 25 May 2021 10:16:45 +0800 [thread overview]
Message-ID: <1fe6c10b-9bc0-ebd6-e69f-8ad69797e780@huawei.com> (raw)
In-Reply-To: <E51F98C9-49F5-45B2-9B2C-4FC309B5C8AB@gmail.com>
Thank you for your comments, I will modify it in the v2 version.
Best regards
Wu Guanghao
在 2021/5/24 22:40, Благодаренко Артём 写道:
> Hello Wu,
>
> Thank you for the fixes.
>
> It looks like free and return operators should be placed in {} block.
>
> {
> free(buf);
> return;
> }
>
> Now function returns any time block is read successfully.
>
> Also, this patch can not be applied cleanly to the master HEAD because of wrong offsets. Please rebase.
>
> Best regards,
> Artem Blagodarenko.
>
>> On 24 May 2021, at 14:20, Wu Guanghao <wuguanghao3@huawei.com> wrote:
>>
>> In zap_sector(), need free buf before return,
>> otherwise it will cause memory leak.
>>
>> Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
>> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
>> Reviewed-by: Wu Bo <wubo40@huawei.com>
>> ---
>> misc/mke2fs.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/misc/mke2fs.c b/misc/mke2fs.c
>> index afbcf486..94f81da9 100644
>> --- a/misc/mke2fs.c
>> +++ b/misc/mke2fs.c
>> @@ -586,6 +586,7 @@ static void zap_sector(ext2_filsys fs, int sect, int nsect)
>> magic = (unsigned int *) (buf + BSD_LABEL_OFFSET);
>> if ((*magic == BSD_DISKMAGIC) ||
>> (*magic == BSD_MAGICDISK))
>> + free(buf);
>> return;
>> }
>> }
>> --
>
> .
>
next prev parent reply other threads:[~2021-05-25 2:16 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-24 11:18 [PATCH 00/12] e2fsprogs: some bugfixs and some code cleanups Wu Guanghao
2021-05-24 11:19 ` [PATCH 01/12] profile_create_node: set magic before strdup(name) to avoid memory leak Wu Guanghao
2021-05-24 11:20 ` [PATCH 02/12] tdb_transaction_recover: fix " Wu Guanghao
2021-05-24 11:20 ` [PATCH 03/12] zap_sector: " Wu Guanghao
2021-05-24 14:40 ` Благодаренко Артём
2021-05-25 2:16 ` Wu Guanghao [this message]
2021-05-24 11:21 ` [PATCH 04/12] ss_add_info_dir: fix memory leak and check whether,NULL pointer Wu Guanghao
2021-05-24 11:21 ` [PATCH 05/12] ss_create_invocation: fix memory leak and check whether NULL pointer Wu Guanghao
2021-05-24 11:23 ` [PATCH 06/12] append_pathname: check the value returned by realloc to avoid segfault Wu Guanghao
2021-05-25 9:37 ` Благодаренко Артём
2021-05-25 11:26 ` Wu Guanghao
2021-05-24 11:23 ` [PATCH 07/12] argv_parse: check return value of malloc in argv_parse() Wu Guanghao
2021-05-25 2:32 ` Wu Guanghao
2021-05-24 11:24 ` [PATCH 08/12] misc: fix potential segmentation fault problem in, scandir() Wu Guanghao
2021-05-24 11:24 ` [PATCH 09/12] lib/ss/error.c: check return value malloc in ss_name() Wu Guanghao
2021-05-24 11:25 ` [PATCH 10/12] hashmap: change return value type of, ext2fs_hashmap_add() Wu Guanghao
2021-05-25 12:45 ` Благодаренко Артём
2021-05-29 9:55 ` Zhiqiang Liu
2021-05-24 11:25 ` [PATCH 11/12] misc/lsattr: check whether path is NULL in, lsattr_dir_proc() Wu Guanghao
2021-05-24 11:26 ` [PATCH 12/12] ext2ed: fix potential NULL pointer dereference in, dupstr() Wu Guanghao
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=1fe6c10b-9bc0-ebd6-e69f-8ad69797e780@huawei.com \
--to=wuguanghao3@huawei.com \
--cc=artem.blagodarenko@gmail.com \
--cc=linfeilong@huawei.com \
--cc=linux-ext4@vger.kernel.org \
--cc=liuzhiqiang26@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.