From: Wu Guanghao <wuguanghao3@huawei.com>
To: linux-ext4@vger.kernel.org,
"Благодаренко Артём" <artem.blagodarenko@gmail.com>
Cc: <liuzhiqiang26@huawei.com>, <linfeilong@huawei.com>
Subject: [PATCH V2 03/12] zap_sector: fix memory leak
Date: Mon, 31 May 2021 09:26:35 +0800 [thread overview]
Message-ID: <3fbdb06d-e897-72da-14c9-89ed680e070f@huawei.com> (raw)
In-Reply-To: <00ad4a90-8a40-24c1-98d9-eb5f0da42436@huawei.com>
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 | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index afbcf486..2f229534 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -585,8 +585,10 @@ static void zap_sector(ext2_filsys fs, int sect, int nsect)
else {
magic = (unsigned int *) (buf + BSD_LABEL_OFFSET);
if ((*magic == BSD_DISKMAGIC) ||
- (*magic == BSD_MAGICDISK))
+ (*magic == BSD_MAGICDISK)) {
+ free(buf);
return;
+ }
}
}
--
next prev parent reply other threads:[~2021-05-31 1:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-31 1:23 [PATCH V2 00/12] e2fsprogs: some bugfixs and some code cleanups Wu Guanghao
2021-05-31 1:26 ` Wu Guanghao [this message]
2021-05-31 1:28 ` [PATCH V2 04/12] ss_add_info_dir: fix memory leak and check whether,NULL pointer Wu Guanghao
2021-05-31 1:30 ` [PATCH V2 06/12] append_pathname: check the value returned by realloc to avoid segfault Wu Guanghao
2021-05-31 1:31 ` [PATCH V2 07/12] argv_parse: check return value of malloc in argv_parse() Wu Guanghao
2021-05-31 1:32 ` [PATCH V2 10/12] hashmap: change return value type of, ext2fs_hashmap_add() Wu Guanghao
2021-05-31 4:28 ` [PATCH V2 00/12] e2fsprogs: some bugfixs and some code cleanups Theodore Ts'o
[not found] ` <e4df8d8a-a5b2-a3cf-7e0d-c5dceb3b39f9@huawei.com>
2021-05-31 8:28 ` Wu Guanghao
2021-06-15 11:27 ` Zhiqiang Liu
-- strict thread matches above, loose matches on Subject: below --
2021-06-30 8:27 [PATCH v2 01/12] profile_create_node: set magic before strdup(name) to avoid memory leak wuguanghao
2021-06-30 8:27 ` [PATCH v2 03/12] zap_sector: fix " wuguanghao
2021-07-16 3:20 ` Theodore Y. Ts'o
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=3fbdb06d-e897-72da-14c9-89ed680e070f@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.