Skip to content

Commit 3fcffd0

Browse files
committed
btrfs-progs: don't check pointer before free()
CodeQL scan reports a few cases of checked free, while this is not done in the rest of the code. Calling free(NULL) is valid, so drop the 'ifs' for consistency. Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 70a3d7d commit 3fcffd0

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

cmds/filesystem-usage.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,7 @@ static int print_filesystem_usage_overall(int fd, const struct array *chunkinfos
673673

674674
exit:
675675

676-
if (sargs)
677-
free(sargs);
676+
free(sargs);
678677

679678
return ret;
680679
}

cmds/qgroup.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -970,8 +970,7 @@ static void __free_btrfs_qgroup(struct btrfs_qgroup *bq)
970970
list_del(&list->next_member);
971971
free(list);
972972
}
973-
if (bq->path)
974-
free((void *)bq->path);
973+
free((void *)bq->path);
975974
free(bq);
976975
}
977976

cmds/replace.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,7 @@ static int cmd_replace_start(const struct cmd_struct *cmd,
359359
return 0;
360360

361361
leave_with_error:
362-
if (dstdev)
363-
free(dstdev);
362+
free(dstdev);
364363
if (fdmnt != -1)
365364
close(fdmnt);
366365
if (fddstdev != -1)

0 commit comments

Comments
 (0)