From: Sheng Yong <shengyong1@huawei.com>
To: jaegeuk@kernel.org, chao@kernel.org,
linux-f2fs-devel@lists.sourceforge.net
Subject: [PATCH] fsck.f2fs: fix double free invalid checkpoint
Date: Mon, 28 Dec 2015 11:33:22 +0000 [thread overview]
Message-ID: <1451302402-21642-1-git-send-email-shengyong1@huawei.com> (raw)
The invalid checkpoin is freed in validate_checkpoint().
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
---
fsck/mount.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/fsck/mount.c b/fsck/mount.c
index fe68f37..7533926 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -469,11 +469,8 @@ int get_valid_checkpoint(struct f2fs_sb_info *sbi)
cur_page = cp2;
sbi->cur_cp = 2;
version = cp2_version;
- } else {
- free(cp1);
- free(cp2);
+ } else
goto fail_no_cp;
- }
MSG(0, "Info: CKPT version = %llx\n", version);
@@ -495,8 +492,10 @@ int get_valid_checkpoint(struct f2fs_sb_info *sbi)
memcpy(ckpt + i * blk_size, cur_page, blk_size);
}
}
- free(cp1);
- free(cp2);
+ if (cp1)
+ free(cp1);
+ if (cp2)
+ free(cp2);
return 0;
fail_no_cp:
--
1.9.1
------------------------------------------------------------------------------
reply other threads:[~2015-12-28 3:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1451302402-21642-1-git-send-email-shengyong1@huawei.com \
--to=shengyong1@huawei.com \
--cc=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
/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;
as well as URLs for NNTP newsgroup(s).