From c17d3b2969a975969593083211de09082c0535fc Mon Sep 17 00:00:00 2001 From: David Sterba Date: Thu, 4 Apr 2024 01:15:04 +0200 Subject: [PATCH] btrfs-progs: initialize all return parameters in btrfs_test_for_multiple_profiles() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported by 'gcc -fanalyzer': common/utils.c:1203:9: warning: use of uninitialized value ‘data’ [CWE-457] [-Wanalyzer-use-of-uninitialized-value] There are several return parameters passed to btrfs_get_string_for_multiple_profiles(), in case it fails early no values are assigned so the free() would be called on some stack initialization value. Initialize all the pointers. Signed-off-by: David Sterba --- common/utils.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/utils.c b/common/utils.c index c303462c..d3df9799 100644 --- a/common/utils.c +++ b/common/utils.c @@ -1196,7 +1196,11 @@ out: */ char *btrfs_test_for_multiple_profiles(int fd) { - char *data, *metadata, *system, *mixed, *types; + char *data = NULL; + char *metadata = NULL; + char *system = NULL; + char *mixed = NULL; + char *types = NULL; btrfs_get_string_for_multiple_profiles(fd, &data, &metadata, &mixed, &system, &types);