All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext2fs_open2: goto cleanup tag when image_header->magic_number != EXT2_ET_MAGIC_E2IMAGE
@ 2022-09-13 13:14 Zhiqiang Liu
  2022-09-13 14:59 ` Ritesh Harjani (IBM)
  0 siblings, 1 reply; 2+ messages in thread
From: Zhiqiang Liu @ 2022-09-13 13:14 UTC (permalink / raw)
  To: tytso, Ext4 Developers List; +Cc: linfeilong, zhanchengbin, wuguanghao


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@huawei.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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ext2fs_open2: goto cleanup tag when image_header->magic_number != EXT2_ET_MAGIC_E2IMAGE
  2022-09-13 13:14 [PATCH] ext2fs_open2: goto cleanup tag when image_header->magic_number != EXT2_ET_MAGIC_E2IMAGE Zhiqiang Liu
@ 2022-09-13 14:59 ` Ritesh Harjani (IBM)
  0 siblings, 0 replies; 2+ messages in thread
From: Ritesh Harjani (IBM) @ 2022-09-13 14:59 UTC (permalink / raw)
  To: Zhiqiang Liu
  Cc: tytso, Ext4 Developers List, linfeilong, zhanchengbin, wuguanghao

On 22/09/13 09:14PM, Zhiqiang Liu wrote:
> 
> 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@huawei.com>
> ---
>  lib/ext2fs/openfs.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Looks good to me. Feel free to add - 
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>

-ritesh

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-13 16:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-13 13:14 [PATCH] ext2fs_open2: goto cleanup tag when image_header->magic_number != EXT2_ET_MAGIC_E2IMAGE Zhiqiang Liu
2022-09-13 14:59 ` Ritesh Harjani (IBM)

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.