From 2e32d2357443d596d8d9067116152ec49be02a4a Mon Sep 17 00:00:00 2001 From: "t.feng" Date: Tue, 29 Nov 2022 17:14:15 +0800 Subject: [PATCH] fs/xfs: Fix memory leaks in XFS module Reference:https://git.savannah.gnu.org/cgit/grub.git/commit?id=2e32d2357443d596d8d9067116152ec49be02a4a Conflict:NA Signed-off-by: t.feng Reviewed-by: Daniel Kiper --- grub-core/fs/xfs.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index ea65902..a601a4c 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -557,7 +557,10 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) if (grub_disk_read (node->data->disk, GRUB_XFS_FSB_TO_BLOCK (node->data, get_fsb (keys, i - 1 + recoffset)) << (node->data->sblock.log2_bsize - GRUB_DISK_SECTOR_BITS), 0, node->data->bsize, leaf)) - return 0; + { + grub_free (leaf); + return 0; + } if ((!node->data->hascrc && grub_strncmp ((char *) leaf->magic, "BMAP", 4)) || @@ -723,6 +726,7 @@ static int iterate_dir_call_hook (grub_uint64_t ino, const char *filename, if (err) { grub_print_error (); + grub_free (fdiro); return 0; } @@ -833,7 +837,10 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, blk << dirblk_log2, dirblk_size, dirblock, 0); if (numread != dirblk_size) - return 0; + { + grub_free (dirblock); + return 0; + } entries = (grub_be_to_cpu32 (tail->leaf_count) - grub_be_to_cpu32 (tail->leaf_stale)); -- 2.19.1