]> git.ipfire.org Git - thirdparty/grub.git/commit
f2fs: Fix gcc9 error -Werror=maybe-uninitialized
authorMichael Chang <mchang@suse.com>
Fri, 17 May 2019 09:00:19 +0000 (17:00 +0800)
committerDaniel Kiper <daniel.kiper@oracle.com>
Mon, 20 May 2019 10:59:00 +0000 (12:59 +0200)
commita06b079a360618ff6c83bc2014045a5ac0c9d072
treecf6655c8e8c3f1514e61c15e455cd2618e325227
parentce946603cf4b6ea0f990412e633085d8c71e1b29
f2fs: Fix gcc9 error -Werror=maybe-uninitialized

The function grub_get_node_path() could return uninitialized offset with
level == 0 if the block is greater than direct_index + 2 * direct_blks +
2 * indirect_blks + dindirect_blks. The uninitialized offset is then used
by function grub_f2fs_get_block() because level == 0 is valid and
meaningful return to be processed.

The fix is to set level = -1 as return value by grub_get_node_path() to
signify an error that the input block cannot be handled. Any caller
should therefore check level is negative or not before processing the
output.

Reported-by: Neil MacLeod <neil@nmacleod.com>
Signed-off-by: Michael Chang <mchang@suse.com>
Tested-by: Neil MacLeod <neil@nmacleod.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/fs/f2fs.c