From: t.feng Date: Tue, 29 Nov 2022 09:14:15 +0000 (+0800) Subject: fs/xfs: Fix memory leaks in XFS module X-Git-Tag: grub-2.12-rc1~196 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e32d2357443d596d8d9067116152ec49be02a4a;p=thirdparty%2Fgrub.git fs/xfs: Fix memory leaks in XFS module Signed-off-by: t.feng Reviewed-by: Daniel Kiper --- diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index d6de7f1a2..b67407690 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -585,7 +585,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)) || @@ -751,6 +754,7 @@ static int iterate_dir_call_hook (grub_uint64_t ino, const char *filename, if (err) { grub_print_error (); + grub_free (fdiro); return 0; } @@ -861,7 +865,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));