From 4adef522cc8eb4915faaea59bda404280ba2da2a Mon Sep 17 00:00:00 2001 From: George Burgess IV Date: Tue, 15 May 2018 15:59:04 -0700 Subject: Fix a double-free On an error here, we'd free `info->sit_blocks` just above this line, return to `generate_f2fs_info`, jump to the `error` label, and call `free_f2fs_info`. `free_f2fs_info` helpfully frees `info->sit_blocks`. Caught by the static analyzer. Bug: None Test: Static analyzer no longer complains. Change-Id: I52a158b35f19736b0bfd9cccf969f8fca9237928 --- f2fs_utils/f2fs_sparseblock.c | 1 + 1 file changed, 1 insertion(+) (limited to 'f2fs_utils') diff --git a/f2fs_utils/f2fs_sparseblock.c b/f2fs_utils/f2fs_sparseblock.c index 95268d0e..c77b626c 100644 --- a/f2fs_utils/f2fs_sparseblock.c +++ b/f2fs_utils/f2fs_sparseblock.c @@ -333,6 +333,7 @@ static int gather_sit_info(int fd, struct f2fs_info *info) if (read_structure(fd, address * F2FS_BLKSIZE, &info->sit_blocks[sit_block], sizeof(struct f2fs_sit_block))) { SLOGE("Could not read sit block at block %"PRIu64, address); free(info->sit_blocks); + info->sit_blocks = NULL; return -1; } } -- cgit v1.2.3