[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <703f5bf7-fd63-ad0a-fcbb-0b5affd31d53@huawei.com>
Date: Tue, 13 Sep 2022 21:14:51 +0800
From: Zhiqiang Liu <liuzhiqiang26@...wei.com>
To: <tytso@....edu>, Ext4 Developers List <linux-ext4@...r.kernel.org>
CC: linfeilong <linfeilong@...wei.com>,
zhanchengbin <zhanchengbin1@...wei.com>,
wuguanghao <wuguanghao3@...wei.com>
Subject: [PATCH] ext2fs_open2: goto cleanup tag when
image_header->magic_number != EXT2_ET_MAGIC_E2IMAGE
In ext2fs_open2(), fs->image_header is assigned by calling io_channel_read_blk,
successfully. If fs->image_header->magic_number is not equal to EXT2_ET_MAGIC_E2IMAGE,
we should go to cleanup tag to free resouce and return errcode (EXT2_ET_MAGIC_E2IMAGE).
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@...wei.com>
---
lib/ext2fs/openfs.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c
index 39229d7c..df73f4f2 100644
--- a/lib/ext2fs/openfs.c
+++ b/lib/ext2fs/openfs.c
@@ -193,8 +193,10 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
fs->image_header);
if (retval)
goto cleanup;
- if (ext2fs_le32_to_cpu(fs->image_header->magic_number) != EXT2_ET_MAGIC_E2IMAGE)
- return EXT2_ET_MAGIC_E2IMAGE;
+ if (ext2fs_le32_to_cpu(fs->image_header->magic_number) != EXT2_ET_MAGIC_E2IMAGE) {
+ retval = EXT2_ET_MAGIC_E2IMAGE;
+ goto cleanup;
+ }
superblock = 1;
block_size = ext2fs_le32_to_cpu(fs->image_header->fs_blocksize);
}
--
2.33.0
Powered by blists - more mailing lists