mdadm-4.3-9.fc44

List of Findings

Error: SHELLCHECK_WARNING (CWE-571): [#def1]
/usr/bin/raid-check:23:12: warning[SC2155]: Declare and assign separately to avoid masking return values.
#   21|   	local dev=""
#   22|   	for dev in $dev_list; do
#   23|-> 	    local sync_action=`cat /sys/block/$dev/md/sync_action`
#   24|   	    if [ "$sync_action" != "idle" ]; then
#   25|   		let busy++

Error: SHELLCHECK_WARNING (CWE-477): [#def2]
/usr/bin/raid-check:73:33: warning[SC2166]: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
#   71|   	# when two or more arrays are on the same physical disk
#   72|   	array_state=`cat /sys/block/$dev/md/array_state`
#   73|-> 	if [ "$array_state" != "clean" -a "$array_state" != "active" ]; then
#   74|   	    continue
#   75|   	fi

Error: SHELLCHECK_WARNING (CWE-477): [#def3]
/usr/bin/raid-check:100:25: warning[SC2166]: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
#   98|       resync_pid=""
#   99|       wait=10
#  100|->     while [ $wait -gt 0 -a -z "$resync_pid" ]; do
#  101|   	sleep 6
#  102|   	let wait--

Error: SHELLCHECK_WARNING (CWE-477): [#def4]
/usr/bin/raid-check:105:24: warning[SC2166]: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
#  103|   	resync_pid=$(ps -ef | awk -v mddev=$dev 'BEGIN { pattern = "^\\[" mddev "_resync]$" } $8 ~ pattern { print $2 }')
#  104|       done
#  105|->     [ -n "$resync_pid" -a -n "$renice" ] &&
#  106|       	renice $renice -p $resync_pid >&/dev/null
#  107|       [ -n "$resync_pid" -a -n "$ionice" ] &&

Error: SHELLCHECK_WARNING (CWE-477): [#def5]
/usr/bin/raid-check:107:24: warning[SC2166]: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
#  105|       [ -n "$resync_pid" -a -n "$renice" ] &&
#  106|       	renice $renice -p $resync_pid >&/dev/null
#  107|->     [ -n "$resync_pid" -a -n "$ionice" ] &&
#  108|       	ionice $ionice -p $resync_pid >&/dev/null
#  109|   done

Error: SHELLCHECK_WARNING (CWE-477): [#def6]
/usr/bin/raid-check:128:29: warning[SC2166]: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.
#  126|   	# be in the device.
#  127|   	raid_lvl=`cat /sys/block/$dev/md/level`
#  128|-> 	if [ "$raid_lvl" = "raid1" -o "$raid_lvl" = "raid10" ]; then
#  129|   	    continue
#  130|   	fi

Error: SHELLCHECK_WARNING (CWE-156): [#def7]
/usr/share/mdadm/mdcheck:36:6: warning[SC2046]: Quote this to prevent word splitting.
#   34|   # convert a /dev/md name into /sys/.../md equivalent
#   35|   sysname() {
#   36|-> 	set `ls -lLd $1`
#   37|   	maj=${5%,}
#   38|   	min=$6

Error: SHELLCHECK_WARNING (CWE-477): [#def8]
/usr/share/mdadm/mdcheck:98:23: warning[SC2166]: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.
#   96|   		start=0
#   97|   		logger -p daemon.info mdcheck start checking $dev
#   98|-> 	elif [ -z "$MD_UUID" -o ! -f "$fl" ]
#   99|   	then
#  100|   		# Nothing to continue here

Error: SHELLCHECK_WARNING (CWE-156): [#def9]
/usr/share/mdadm/mdcheck:121:9: warning[SC2046]: Quote this to prevent word splitting.
#  119|   fi
#  120|   
#  121|-> while [ `date +%s` -lt $endtime ]
#  122|   do
#  123|   	any=

Error: SHELLCHECK_WARNING (CWE-156): [#def10]
/usr/share/mdadm/mdcheck:165:47: warning[SC2046]: Quote this to prevent word splitting.
#  163|   	echo idle > $sys/md/sync_action
#  164|   	cat $sys/md/sync_min > $fl
#  165|-> 	logger -p daemon.info pause checking $dev at `cat $fl`
#  166|   done

Error: COMPILER_WARNING: [#def11]
mdadm-4.3/Assemble.c: scope_hint: In function ‘Assemble’
mdadm-4.3/Assemble.c:1410:55: warning[-Wunused-but-set-variable=]: variable ‘replcnt’ set but not used
# 1410 |         unsigned int okcnt, sparecnt, rebuilding_cnt, replcnt, journalcnt;
#      |                                                       ^~~~~~~
# 1408|   	int bestcnt = 0;
# 1409|   	int devcnt;
# 1410|-> 	unsigned int okcnt, sparecnt, rebuilding_cnt, replcnt, journalcnt;
# 1411|   	int journal_clean = 0;
# 1412|   	int i;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def12]
mdadm-4.3/Create.c:282:22: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘fd’
mdadm-4.3/Create.c:269:12: branch_false: following ‘false’ branch (when ‘have_container == 0’)...
mdadm-4.3/Create.c:272:21: branch_false: ...to here
mdadm-4.3/Create.c:275:30: acquire_resource: opened here
mdadm-4.3/Create.c:277:20: branch_false: following ‘false’ branch (when ‘fd >= 0’)...
mdadm-4.3/Create.c:282:22: branch_false: ...to here
mdadm-4.3/Create.c:282:22: throw: if ‘fstat_is_blkdev’ throws an exception...
mdadm-4.3/Create.c:282:22: danger: ‘fd’ leaks here; was opened at [(3)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/2)
#  280|   			return 1;
#  281|   		}
#  282|-> 		if (!fstat_is_blkdev(fd, dv->devname, &rdev))
#  283|   			return 1;
#  284|   		info->disk.major = major(rdev);

Error: GCC_ANALYZER_WARNING (CWE-775): [#def13]
mdadm-4.3/Create.c:566:21: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(*devlist.devname, 0)’
mdadm-4.3/Create.c:499:21: branch_false: following ‘false’ branch...
mdadm-4.3/Create.c:504:13: branch_false: ...to here
mdadm-4.3/Create.c:536:12: branch_false: following ‘false’ branch...
mdadm-4.3/Create.c:540:13: branch_false: ...to here
mdadm-4.3/Create.c:557:12: branch_true: following ‘true’ branch...
mdadm-4.3/Create.c:564:22: acquire_resource: opened here
mdadm-4.3/Create.c:565:20: branch_true: following ‘true’ branch...
mdadm-4.3/Create.c:566:21: branch_true: ...to here
mdadm-4.3/Create.c:566:21: throw: if ‘md_get_array_info’ throws an exception...
mdadm-4.3/Create.c:566:21: danger: ‘open(*devlist.devname, 0)’ leaks here; was opened at [(7)](sarif:/runs/0/results/1/codeFlows/0/threadFlows/0/locations/6)
#  564|   		fd = open(devlist->devname, O_RDONLY);
#  565|   		if (fd >= 0 &&
#  566|-> 		    md_get_array_info(fd, &inf) == 0 && inf.raid_disks == 0) {
#  567|   			/* yep, looks like a container */
#  568|   			if (st) {

Error: COMPILER_WARNING: [#def14]
mdadm-4.3/Detail.c: scope_hint: In function ‘Detail’
mdadm-4.3/Detail.c:68:13: warning[-Wunused-but-set-variable=]: variable ‘failed’ set but not used
#   68 |         int failed = 0;
#      |             ^~~~~~
#   66|   	int spares = 0;
#   67|   	struct stat stb;
#   68|-> 	int failed = 0;
#   69|   	struct supertype *st = NULL;
#   70|   	char *subarray = NULL;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def15]
mdadm-4.3/Detail.c:78:18: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(dev, 0)’
mdadm-4.3/Detail.c:57:18: acquire_resource: opened here
mdadm-4.3/Detail.c:86:12: branch_false: following ‘false’ branch...
mdadm-4.3/Detail.c:91:15: branch_false: ...to here
mdadm-4.3/Detail.c:91:15: throw: if ‘sysfs_read’ throws an exception...
mdadm-4.3/Detail.c:78:18: danger: ‘open(dev, 0)’ leaks here; was opened at [(1)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/0)
#   76|   	char *container = NULL;
#   77|   
#   78|-> 	int rv = c->test ? 4 : 1;
#   79|   	int avail_disks = 0;
#   80|   	char *avail = NULL;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def16]
mdadm-4.3/Dump.c:129:22: warning[-Wanalyzer-malloc-leak]: leak of ‘opendir("/dev/disk/by-id")’
mdadm-4.3/Dump.c:23:5: enter_function: entry to ‘Dump_metadata’
mdadm-4.3/Dump.c:41:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:42:23: branch_false: ...to here
mdadm-4.3/Dump.c:41:13: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:48:14: branch_false: ...to here
mdadm-4.3/Dump.c:49:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:54:14: branch_false: ...to here
mdadm-4.3/Dump.c:54:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:59:12: branch_false: ...to here
mdadm-4.3/Dump.c:68:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:74:13: branch_false: ...to here
mdadm-4.3/Dump.c:74:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:81:16: branch_false: ...to here
mdadm-4.3/Dump.c:86:9: call_function: calling ‘xasprintf’ from ‘Dump_metadata’
mdadm-4.3/Dump.c:86:9: return_function: returning to ‘Dump_metadata’ from ‘xasprintf’
mdadm-4.3/Dump.c:88:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:95:13: branch_false: ...to here
mdadm-4.3/Dump.c:95:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:104:13: branch_false: ...to here
mdadm-4.3/Dump.c:104:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:113:13: branch_false: ...to here
mdadm-4.3/Dump.c:118:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:124:16: branch_false: ...to here
mdadm-4.3/Dump.c:124:16: acquire_memory: allocated here
mdadm-4.3/Dump.c:125:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:125:12: branch_false: ...to here
mdadm-4.3/Dump.c:129:22: throw: if ‘readdir’ throws an exception...
mdadm-4.3/Dump.c:129:22: danger: ‘opendir("/dev/disk/by-id")’ leaks here; was allocated at [(27)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/26)
#  127|   		return 0;
#  128|   	}
#  129|-> 	while ((de = readdir(dirp)) != NULL) {
#  130|   		char *p = NULL;
#  131|   		if (de->d_name[0] == '.')

Error: GCC_ANALYZER_WARNING (CWE-401): [#def17]
mdadm-4.3/Dump.c:205:35: warning[-Wanalyzer-malloc-leak]: leak of ‘opendir(dir)’
mdadm-4.3/Dump.c:176:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:180:30: branch_false: ...to here
mdadm-4.3/Dump.c:186:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:191:14: branch_false: ...to here
mdadm-4.3/Dump.c:191:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:196:23: branch_false: ...to here
mdadm-4.3/Dump.c:196:12: branch_true: following ‘true’ branch...
mdadm-4.3/Dump.c:198:26: branch_true: ...to here
mdadm-4.3/Dump.c:198:26: acquire_memory: allocated here
mdadm-4.3/Dump.c:205:24: branch_true: following ‘true’ branch...
mdadm-4.3/Dump.c:205:35: branch_true: ...to here
mdadm-4.3/Dump.c:205:35: throw: if ‘readdir’ throws an exception...
mdadm-4.3/Dump.c:205:35: danger: ‘opendir(dir)’ leaks here; was allocated at [(9)](sarif:/runs/0/results/1/codeFlows/0/threadFlows/0/locations/8)
#  203|   		fstat(fd, &dstb);
#  204|   
#  205|-> 		while (d && (de = readdir(d)) != NULL) {
#  206|   			if (de->d_name[0] == '.')
#  207|   				continue;

Error: GCC_ANALYZER_WARNING (CWE-688): [#def18]
mdadm-4.3/Dump.c:244:17: warning[-Wanalyzer-null-argument]: use of NULL ‘opendir(dir)’ where non-null expected
mdadm-4.3/Dump.c:176:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:180:30: branch_false: ...to here
mdadm-4.3/Dump.c:186:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:191:14: branch_false: ...to here
mdadm-4.3/Dump.c:191:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:196:23: branch_false: ...to here
mdadm-4.3/Dump.c:196:12: branch_true: following ‘true’ branch...
mdadm-4.3/Dump.c:198:26: branch_true: ...to here
mdadm-4.3/Dump.c:198:26: acquire_memory: allocated here
mdadm-4.3/Dump.c:205:24: release_memory: assuming ‘opendir(dir)’ is NULL
mdadm-4.3/Dump.c:205:24: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:244:17: branch_false: ...to here
mdadm-4.3/Dump.c:244:17: danger: argument 1 (‘opendir(dir)’) NULL where non-null expected
#  242|   			return 1;
#  243|   		}
#  244|-> 		closedir(d);
#  245|   		if (!chosen) {
#  246|   			/* One last chance: try basename of device */

Error: GCC_ANALYZER_WARNING (CWE-401): [#def19]
mdadm-4.3/Dump.c:269:14: warning[-Wanalyzer-malloc-leak]: leak of ‘fname’
mdadm-4.3/Dump.c:176:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:180:30: branch_false: ...to here
mdadm-4.3/Dump.c:186:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:191:14: branch_false: ...to here
mdadm-4.3/Dump.c:191:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:196:23: branch_false: ...to here
mdadm-4.3/Dump.c:196:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:260:25: branch_false: ...to here
mdadm-4.3/Dump.c:260:25: acquire_memory: allocated here
mdadm-4.3/Dump.c:262:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:269:14: branch_false: ...to here
mdadm-4.3/Dump.c:269:14: throw: if ‘open’ throws an exception...
mdadm-4.3/Dump.c:269:14: danger: ‘fname’ leaks here; was allocated at [(9)](sarif:/runs/0/results/3/codeFlows/0/threadFlows/0/locations/8)
#  267|   	}
#  268|   
#  269|-> 	fl = open(fname, O_RDONLY);
#  270|   	if (!fl) {
#  271|   		pr_err("Could not open %s for --restore.\n",

Error: GCC_ANALYZER_WARNING (CWE-775): [#def20]
mdadm-4.3/Dump.c:271:17: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(fname, 0)’
mdadm-4.3/Dump.c:158:5: enter_function: entry to ‘Restore_metadata’
mdadm-4.3/Dump.c:176:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:180:30: branch_false: ...to here
mdadm-4.3/Dump.c:186:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:191:14: branch_false: ...to here
mdadm-4.3/Dump.c:191:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:196:23: branch_false: ...to here
mdadm-4.3/Dump.c:196:12: branch_true: following ‘true’ branch...
mdadm-4.3/Dump.c:198:26: branch_true: ...to here
mdadm-4.3/Dump.c:205:24: branch_true: following ‘true’ branch...
mdadm-4.3/Dump.c:205:35: branch_true: ...to here
mdadm-4.3/Dump.c:245:20: branch_true: following ‘true’ branch (when ‘chosen’ is NULL)...
mdadm-4.3/Dump.c:247:38: branch_true: ...to here
mdadm-4.3/Dump.c:252:25: call_function: calling ‘xasprintf’ from ‘Restore_metadata’
mdadm-4.3/Dump.c:252:25: return_function: returning to ‘Restore_metadata’ from ‘xasprintf’
mdadm-4.3/Dump.c:253:28: branch_true: following ‘true’ branch...
mdadm-4.3/Dump.c:254:33: branch_true: ...to here
mdadm-4.3/Dump.c:262:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:269:14: branch_false: ...to here
mdadm-4.3/Dump.c:269:14: acquire_resource: opened here
mdadm-4.3/Dump.c:315:9: throw: if ‘close’ throws an exception...
mdadm-4.3/Dump.c:271:17: danger: ‘open(fname, 0)’ leaks here; was opened at [(23)](sarif:/runs/0/results/4/codeFlows/0/threadFlows/0/locations/22)
#  269|   	fl = open(fname, O_RDONLY);
#  270|   	if (!fl) {
#  271|-> 		pr_err("Could not open %s for --restore.\n",
#  272|   		       fname);
#  273|   		goto err;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def21]
mdadm-4.3/Dump.c:275:13: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(fname, 0)’
mdadm-4.3/Dump.c:176:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:180:30: branch_false: ...to here
mdadm-4.3/Dump.c:186:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:191:14: branch_false: ...to here
mdadm-4.3/Dump.c:191:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:196:23: branch_false: ...to here
mdadm-4.3/Dump.c:196:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:260:25: branch_false: ...to here
mdadm-4.3/Dump.c:262:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:269:14: branch_false: ...to here
mdadm-4.3/Dump.c:269:14: acquire_resource: opened here
mdadm-4.3/Dump.c:270:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:275:13: branch_false: ...to here
mdadm-4.3/Dump.c:275:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:280:34: branch_false: ...to here
mdadm-4.3/Dump.c:280:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:285:12: branch_false: ...to here
mdadm-4.3/Dump.c:285:12: branch_true: following ‘true’ branch (when ‘st’ is NULL)...
mdadm-4.3/Dump.c:286:22: branch_true: ...to here
mdadm-4.3/Dump.c:286:22: throw: if ‘guess_super_type’ throws an exception...
mdadm-4.3/Dump.c:275:13: danger: ‘open(fname, 0)’ leaks here; was opened at [(11)](sarif:/runs/0/results/5/codeFlows/0/threadFlows/0/locations/10)
#  273|   		goto err;
#  274|   	}
#  275|-> 	if (stat(fname, &stb) != 0) {
#  276|   		pr_err("Could not stat %s for --restore.\n",
#  277|   		       fname);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def22]
mdadm-4.3/Dump.c:286:22: warning[-Wanalyzer-malloc-leak]: leak of ‘fname’
mdadm-4.3/Dump.c:176:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:180:30: branch_false: ...to here
mdadm-4.3/Dump.c:186:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:191:14: branch_false: ...to here
mdadm-4.3/Dump.c:191:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:196:23: branch_false: ...to here
mdadm-4.3/Dump.c:196:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:260:25: branch_false: ...to here
mdadm-4.3/Dump.c:260:25: acquire_memory: allocated here
mdadm-4.3/Dump.c:262:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:269:14: branch_false: ...to here
mdadm-4.3/Dump.c:270:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:275:13: branch_false: ...to here
mdadm-4.3/Dump.c:275:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:280:34: branch_false: ...to here
mdadm-4.3/Dump.c:280:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:285:12: branch_false: ...to here
mdadm-4.3/Dump.c:285:12: branch_true: following ‘true’ branch (when ‘st’ is NULL)...
mdadm-4.3/Dump.c:286:22: branch_true: ...to here
mdadm-4.3/Dump.c:286:22: throw: if ‘guess_super_type’ throws an exception...
mdadm-4.3/Dump.c:286:22: danger: ‘fname’ leaks here; was allocated at [(9)](sarif:/runs/0/results/7/codeFlows/0/threadFlows/0/locations/8)
#  284|   	}
#  285|   	if (st == NULL)
#  286|-> 		st = guess_super_type(fl, guess_array);
#  287|   	if (!st) {
#  288|   		pr_err("Cannot find metadata on %s\n", fname);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def23]
mdadm-4.3/Dump.c:292:13: warning[-Wanalyzer-malloc-leak]: leak of ‘fname’
mdadm-4.3/Dump.c:176:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:180:30: branch_false: ...to here
mdadm-4.3/Dump.c:186:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:191:14: branch_false: ...to here
mdadm-4.3/Dump.c:191:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:196:23: branch_false: ...to here
mdadm-4.3/Dump.c:196:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:260:25: branch_false: ...to here
mdadm-4.3/Dump.c:260:25: acquire_memory: allocated here
mdadm-4.3/Dump.c:262:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:269:14: branch_false: ...to here
mdadm-4.3/Dump.c:270:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:275:13: branch_false: ...to here
mdadm-4.3/Dump.c:275:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:280:34: branch_false: ...to here
mdadm-4.3/Dump.c:280:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:285:12: branch_false: ...to here
mdadm-4.3/Dump.c:285:12: branch_false: following ‘false’ branch (when ‘st’ is non-NULL)...
mdadm-4.3/Dump.c:291:9: branch_false: ...to here
mdadm-4.3/Dump.c:292:13: throw: if the called function throws an exception...
mdadm-4.3/Dump.c:292:13: danger: ‘fname’ leaks here; was allocated at [(9)](sarif:/runs/0/results/8/codeFlows/0/threadFlows/0/locations/8)
#  290|   	}
#  291|   	st->ignore_hw_compat = 1;
#  292|-> 	if (st->ss->load_super(st, fl, NULL) != 0) {
#  293|   		pr_err("No %s metadata found on %s\n",
#  294|   		       st->ss->name, fname);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def24]
mdadm-4.3/Dump.c:302:13: warning[-Wanalyzer-malloc-leak]: leak of ‘fname’
mdadm-4.3/Dump.c:176:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:180:30: branch_false: ...to here
mdadm-4.3/Dump.c:186:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:191:14: branch_false: ...to here
mdadm-4.3/Dump.c:191:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:196:23: branch_false: ...to here
mdadm-4.3/Dump.c:196:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:260:25: branch_false: ...to here
mdadm-4.3/Dump.c:260:25: acquire_memory: allocated here
mdadm-4.3/Dump.c:262:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:269:14: branch_false: ...to here
mdadm-4.3/Dump.c:270:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:275:13: branch_false: ...to here
mdadm-4.3/Dump.c:275:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:280:34: branch_false: ...to here
mdadm-4.3/Dump.c:280:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:285:12: branch_false: ...to here
mdadm-4.3/Dump.c:285:12: branch_false: following ‘false’ branch (when ‘st’ is non-NULL)...
mdadm-4.3/Dump.c:291:9: branch_false: ...to here
mdadm-4.3/Dump.c:292:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:297:13: branch_false: ...to here
mdadm-4.3/Dump.c:297:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:302:13: branch_false: ...to here
mdadm-4.3/Dump.c:302:13: throw: if the called function throws an exception...
mdadm-4.3/Dump.c:302:13: danger: ‘fname’ leaks here; was allocated at [(9)](sarif:/runs/0/results/9/codeFlows/0/threadFlows/0/locations/8)
#  300|   		goto err;
#  301|   	}
#  302|-> 	if (st->ss->copy_metadata(st, fl, fd) != 0) {
#  303|   		pr_err("Failed to copy metadata from %s to %s\n",
#  304|   		       fname, dev);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def25]
mdadm-4.3/Dump.c:309:9: warning[-Wanalyzer-malloc-leak]: leak of ‘fname’
mdadm-4.3/Dump.c:176:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:180:30: branch_false: ...to here
mdadm-4.3/Dump.c:186:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:191:14: branch_false: ...to here
mdadm-4.3/Dump.c:191:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:196:23: branch_false: ...to here
mdadm-4.3/Dump.c:196:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:260:25: branch_false: ...to here
mdadm-4.3/Dump.c:260:25: acquire_memory: allocated here
mdadm-4.3/Dump.c:262:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:269:14: branch_false: ...to here
mdadm-4.3/Dump.c:270:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:275:13: branch_false: ...to here
mdadm-4.3/Dump.c:275:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:280:34: branch_false: ...to here
mdadm-4.3/Dump.c:280:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:285:12: branch_false: ...to here
mdadm-4.3/Dump.c:285:12: branch_false: following ‘false’ branch (when ‘st’ is non-NULL)...
mdadm-4.3/Dump.c:291:9: branch_false: ...to here
mdadm-4.3/Dump.c:292:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:297:13: branch_false: ...to here
mdadm-4.3/Dump.c:297:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:302:13: branch_false: ...to here
mdadm-4.3/Dump.c:302:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:307:13: branch_false: ...to here
mdadm-4.3/Dump.c:309:9: throw: if ‘close’ throws an exception...
mdadm-4.3/Dump.c:309:9: danger: ‘fname’ leaks here; was allocated at [(9)](sarif:/runs/0/results/10/codeFlows/0/threadFlows/0/locations/8)
#  307|   	if (c->verbose >= 0)
#  308|   		printf("%s restored from %s.\n", dev, fname);
#  309|-> 	close(fl);
#  310|   	close(fd);
#  311|   	free(fname);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def26]
mdadm-4.3/Dump.c:310:9: warning[-Wanalyzer-malloc-leak]: leak of ‘fname’
mdadm-4.3/Dump.c:176:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:180:30: branch_false: ...to here
mdadm-4.3/Dump.c:186:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:191:14: branch_false: ...to here
mdadm-4.3/Dump.c:191:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:196:23: branch_false: ...to here
mdadm-4.3/Dump.c:196:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:260:25: branch_false: ...to here
mdadm-4.3/Dump.c:260:25: acquire_memory: allocated here
mdadm-4.3/Dump.c:262:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:269:14: branch_false: ...to here
mdadm-4.3/Dump.c:270:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:275:13: branch_false: ...to here
mdadm-4.3/Dump.c:275:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:280:34: branch_false: ...to here
mdadm-4.3/Dump.c:280:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:285:12: branch_false: ...to here
mdadm-4.3/Dump.c:285:12: branch_false: following ‘false’ branch (when ‘st’ is non-NULL)...
mdadm-4.3/Dump.c:291:9: branch_false: ...to here
mdadm-4.3/Dump.c:292:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:297:13: branch_false: ...to here
mdadm-4.3/Dump.c:297:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:302:13: branch_false: ...to here
mdadm-4.3/Dump.c:302:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:307:13: branch_false: ...to here
mdadm-4.3/Dump.c:310:9: throw: if ‘close’ throws an exception...
mdadm-4.3/Dump.c:310:9: danger: ‘fname’ leaks here; was allocated at [(9)](sarif:/runs/0/results/11/codeFlows/0/threadFlows/0/locations/8)
#  308|   		printf("%s restored from %s.\n", dev, fname);
#  309|   	close(fl);
#  310|-> 	close(fd);
#  311|   	free(fname);
#  312|   	return 0;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def27]
mdadm-4.3/Dump.c:315:9: warning[-Wanalyzer-malloc-leak]: leak of ‘fname’
mdadm-4.3/Dump.c:176:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:180:30: branch_false: ...to here
mdadm-4.3/Dump.c:186:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:191:14: branch_false: ...to here
mdadm-4.3/Dump.c:191:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:196:23: branch_false: ...to here
mdadm-4.3/Dump.c:196:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:260:25: branch_false: ...to here
mdadm-4.3/Dump.c:260:25: acquire_memory: allocated here
mdadm-4.3/Dump.c:262:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:269:14: branch_false: ...to here
mdadm-4.3/Dump.c:270:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:275:13: branch_false: ...to here
mdadm-4.3/Dump.c:275:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:280:34: branch_false: ...to here
mdadm-4.3/Dump.c:280:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:285:12: branch_false: ...to here
mdadm-4.3/Dump.c:287:12: branch_true: following ‘true’ branch...
mdadm-4.3/Dump.c:288:17: branch_true: ...to here
mdadm-4.3/Dump.c:315:9: throw: if ‘close’ throws an exception...
mdadm-4.3/Dump.c:315:9: danger: ‘fname’ leaks here; was allocated at [(9)](sarif:/runs/0/results/12/codeFlows/0/threadFlows/0/locations/8)
#  313|   
#  314|   err:
#  315|-> 	close(fd);
#  316|   	close(fl);
#  317|   	free(fname);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def28]
mdadm-4.3/Dump.c:316:9: warning[-Wanalyzer-malloc-leak]: leak of ‘fname’
mdadm-4.3/Dump.c:176:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:180:30: branch_false: ...to here
mdadm-4.3/Dump.c:186:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:191:14: branch_false: ...to here
mdadm-4.3/Dump.c:191:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:196:23: branch_false: ...to here
mdadm-4.3/Dump.c:196:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:260:25: branch_false: ...to here
mdadm-4.3/Dump.c:260:25: acquire_memory: allocated here
mdadm-4.3/Dump.c:262:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:269:14: branch_false: ...to here
mdadm-4.3/Dump.c:270:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:275:13: branch_false: ...to here
mdadm-4.3/Dump.c:275:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:280:34: branch_false: ...to here
mdadm-4.3/Dump.c:280:12: branch_false: following ‘false’ branch...
mdadm-4.3/Dump.c:285:12: branch_false: ...to here
mdadm-4.3/Dump.c:287:12: branch_true: following ‘true’ branch...
mdadm-4.3/Dump.c:288:17: branch_true: ...to here
mdadm-4.3/Dump.c:316:9: throw: if ‘close’ throws an exception...
mdadm-4.3/Dump.c:316:9: danger: ‘fname’ leaks here; was allocated at [(9)](sarif:/runs/0/results/13/codeFlows/0/threadFlows/0/locations/8)
#  314|   err:
#  315|   	close(fd);
#  316|-> 	close(fl);
#  317|   	free(fname);
#  318|   	return 1;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def29]
mdadm-4.3/Grow.c:4704:26: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(backup_file, 0)’
mdadm-4.3/Grow.c:4690:45: branch_true: following ‘true’ branch (when ‘i < cnt’)...
mdadm-4.3/Grow.c:4704:26: branch_true: ...to here
mdadm-4.3/Grow.c:4704:20: branch_true: following ‘true’ branch...
mdadm-4.3/Grow.c:4705:30: branch_true: ...to here
mdadm-4.3/Grow.c:4705:30: acquire_resource: opened here
mdadm-4.3/Grow.c:4690:45: branch_true: following ‘true’ branch (when ‘i < cnt’)...
mdadm-4.3/Grow.c:4704:26: branch_true: ...to here
mdadm-4.3/Grow.c:4704:20: branch_true: following ‘true’ branch...
mdadm-4.3/Grow.c:4705:30: branch_true: ...to here
mdadm-4.3/Grow.c:4705:30: throw: if ‘open’ throws an exception...
mdadm-4.3/Grow.c:4704:26: danger: ‘open(backup_file, 0)’ leaks here; was opened at [(5)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/4)
# 4702|   		 * else restore data and update all superblocks
# 4703|   		 */
# 4704|-> 		if (i == old_disks-1) {
# 4705|   			fd = open(backup_file, O_RDONLY);
# 4706|   			if (fd<0) {

Error: GCC_ANALYZER_WARNING (CWE-775): [#def30]
mdadm-4.3/Grow.c:4713:25: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘fd’
mdadm-4.3/Grow.c:4690:45: branch_true: following ‘true’ branch (when ‘i < cnt’)...
mdadm-4.3/Grow.c:4704:26: branch_true: ...to here
mdadm-4.3/Grow.c:4704:20: branch_true: following ‘true’ branch...
mdadm-4.3/Grow.c:4705:30: branch_true: ...to here
mdadm-4.3/Grow.c:4705:30: acquire_resource: opened here
mdadm-4.3/Grow.c:4690:45: branch_true: following ‘true’ branch (when ‘i < cnt’)...
mdadm-4.3/Grow.c:4704:26: branch_true: ...to here
mdadm-4.3/Grow.c:4704:20: branch_false: following ‘false’ branch...
mdadm-4.3/Grow.c:4713:36: branch_false: ...to here
mdadm-4.3/Grow.c:4714:28: branch_false: following ‘false’ branch (when ‘fd >= 0’)...
mdadm-4.3/Grow.c:4716:29: branch_false: ...to here
mdadm-4.3/Grow.c:4716:29: throw: if the called function throws an exception...
mdadm-4.3/Grow.c:4713:25: danger: ‘fd’ leaks here; was opened at [(5)](sarif:/runs/0/results/1/codeFlows/0/threadFlows/0/locations/4)
# 4711|   			devname = backup_file;
# 4712|   		} else {
# 4713|-> 			fd = fdlist[i];
# 4714|   			if (fd < 0)
# 4715|   				continue;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def31]
mdadm-4.3/Grow.c:4731:20: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘fd’
mdadm-4.3/Grow.c:4690:45: branch_true: following ‘true’ branch (when ‘i < cnt’)...
mdadm-4.3/Grow.c:4704:26: branch_true: ...to here
mdadm-4.3/Grow.c:4705:30: acquire_resource: opened here
mdadm-4.3/Grow.c:4731:20: danger: ‘fd’ leaks here; was opened at [(3)](sarif:/runs/0/results/5/codeFlows/0/threadFlows/0/locations/2)
# 4729|   			devname = namebuf;
# 4730|   		}
# 4731|-> 		if (read(fd, &bsb, sizeof(bsb)) != sizeof(bsb)) {
# 4732|   			if (verbose)
# 4733|   				pr_err("Cannot read from %s\n", devname);

Error: GCC_ANALYZER_WARNING (CWE-465): [#def32]
mdadm-4.3/Incremental.c:144:15: warning[-Wanalyzer-deref-before-check]: check of ‘devlist’ for NULL after already dereferencing it
mdadm-4.3/Incremental.c:110:12: branch_false: following ‘false’ branch...
mdadm-4.3/Incremental.c:112:15: branch_false: ...to here
mdadm-4.3/Incremental.c:113:12: branch_false: following ‘false’ branch...
mdadm-4.3/Incremental.c:120:13: branch_false: ...to here
mdadm-4.3/Incremental.c:120:12: branch_false: following ‘false’ branch...
mdadm-4.3/Incremental.c:120:12: branch_false: ...to here
mdadm-4.3/Incremental.c:144:15: danger: pointer ‘devlist’ is checked for NULL here but it was already dereferenced at [(1)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/0)
#  142|   	/* 1/ Check if device is permitted by mdadm.conf */
#  143|   
#  144|-> 	for (;devlist; devlist = devlist->next)
#  145|   		if (conf_test_dev(devlist->devname))
#  146|   			break;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def33]
mdadm-4.3/Incremental.c:1077:22: warning[-Wanalyzer-malloc-leak]: leak of ‘opendir("/dev/disk/by-path")’
mdadm-4.3/Incremental.c:1074:15: acquire_memory: allocated here
mdadm-4.3/Incremental.c:1075:12: branch_false: following ‘false’ branch...
mdadm-4.3/Incremental.c:1075:12: branch_false: ...to here
mdadm-4.3/Incremental.c:1077:22: throw: if ‘readdir’ throws an exception...
mdadm-4.3/Incremental.c:1077:22: danger: ‘opendir("/dev/disk/by-path")’ leaks here; was allocated at [(1)](sarif:/runs/0/results/1/codeFlows/0/threadFlows/0/locations/0)
# 1075|   	if (!dir)
# 1076|   		return 1;
# 1077|-> 	while ((de = readdir(dir)) != NULL) {
# 1078|   		char *ep;
# 1079|   		struct dev_policy *pol2 = NULL;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def34]
mdadm-4.3/Incremental.c:1120:21: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(devname, 0)’
mdadm-4.3/Incremental.c:1075:12: branch_false: following ‘false’ branch...
mdadm-4.3/Incremental.c:1075:12: branch_false: ...to here
mdadm-4.3/Incremental.c:1077:16: branch_true: following ‘true’ branch...
mdadm-4.3/Incremental.c:1080:36: branch_true: ...to here
mdadm-4.3/Incremental.c:1088:20: branch_false: following ‘false’ branch...
mdadm-4.3/Incremental.c:1106:20: branch_false: following ‘false’ branch...
mdadm-4.3/Incremental.c:1110:17: branch_false: ...to here
mdadm-4.3/Incremental.c:1113:20: branch_false: following ‘false’ branch...
mdadm-4.3/Incremental.c:1117:22: branch_false: ...to here
mdadm-4.3/Incremental.c:1117:22: acquire_resource: opened here
mdadm-4.3/Incremental.c:1118:20: branch_false: following ‘false’ branch...
mdadm-4.3/Incremental.c:1120:21: branch_false: ...to here
mdadm-4.3/Incremental.c:1120:21: throw: if ‘get_dev_size’ throws an exception...
mdadm-4.3/Incremental.c:1120:21: danger: ‘open(devname, 0)’ leaks here; was opened at [(11)](sarif:/runs/0/results/2/codeFlows/0/threadFlows/0/locations/10)
# 1118|   		if (fd < 0)
# 1119|   			goto next;
# 1120|-> 		if (get_dev_size(fd, devname, &devsectors) == 0)
# 1121|   			goto next;
# 1122|   		devsectors >>= 9;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def35]
mdadm-4.3/Incremental.c:1434:42: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(devname, 0)’
mdadm-4.3/Incremental.c:1431:12: branch_true: following ‘true’ branch...
mdadm-4.3/Incremental.c:1432:26: branch_true: ...to here
mdadm-4.3/Incremental.c:1432:26: acquire_resource: opened here
mdadm-4.3/Incremental.c:1433:20: branch_true: following ‘true’ branch...
mdadm-4.3/Incremental.c:1434:42: branch_true: ...to here
mdadm-4.3/Incremental.c:1434:42: throw: if ‘fd2devnm’ throws an exception...
mdadm-4.3/Incremental.c:1434:42: danger: ‘open(devname, 0)’ leaks here; was opened at [(3)](sarif:/runs/0/results/3/codeFlows/0/threadFlows/0/locations/2)
# 1432|   		int fd = open(devname, O_RDONLY);
# 1433|   		if (fd >= 0) {
# 1434|-> 			mdname = xstrdup(fd2devnm(fd));
# 1435|   			close(fd);
# 1436|   		}

Error: GCC_ANALYZER_WARNING (CWE-775): [#def36]
mdadm-4.3/Kill.c:60:27: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(dev,  <unknown>)’
mdadm-4.3/Kill.c:49:14: acquire_resource: opened here
mdadm-4.3/Kill.c:50:12: branch_false: following ‘false’ branch...
mdadm-4.3/Kill.c:56:12: branch_false: ...to here
mdadm-4.3/Kill.c:56:12: branch_false: following ‘false’ branch (when ‘st’ is non-NULL)...
mdadm-4.3/Kill.c:60:27: branch_false: ...to here
mdadm-4.3/Kill.c:60:13: branch_true: following ‘true’ branch...
mdadm-4.3/Kill.c:61:20: branch_true: ...to here
mdadm-4.3/Kill.c:60:27: danger: ‘open(dev,  <unknown>)’ leaks here; was opened at [(1)](sarif:/runs/0/results/1/codeFlows/0/threadFlows/0/locations/0)
#   58|   		free_super = true;
#   59|   	}
#   60|-> 	if (st == NULL || st->ss->init_super == NULL) {
#   61|   		if (verbose >= 0)
#   62|   			pr_err("Unrecognised md component device - %s\n", dev);

Error: GCC_ANALYZER_WARNING (CWE-775): [#def37]
mdadm-4.3/Manage.c:209:24: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘fd’
mdadm-4.3/Manage.c:206:23: branch_true: following ‘true’ branch...
mdadm-4.3/Manage.c:207:25: branch_true: ...to here
mdadm-4.3/Manage.c:207:25: acquire_resource: opened here
mdadm-4.3/Manage.c:206:16: branch_false: following ‘false’ branch (when ‘fd >= 0’)...
mdadm-4.3/Manage.c:209:24: branch_false: ...to here
mdadm-4.3/Manage.c:209:24: throw: if ‘fd2devnm’ throws an exception...
mdadm-4.3/Manage.c:209:24: danger: ‘fd’ leaks here; was opened at [(3)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/2)
#  207|   		       ?open(devname, O_RDONLY|O_EXCL)
#  208|   		       :open_dev_flags(devnm, O_RDONLY|O_EXCL))) < 0 ||
#  209|-> 		strcmp(fd2devnm(fd), devnm) != 0) && container[0] &&
#  210|   	       mdmon_running(container) && count) {
#  211|   		/* Can't open, so something might be wrong.  However it

Error: GCC_ANALYZER_WARNING (CWE-775): [#def38]
mdadm-4.3/Manage.c:1818:19: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(to_devname, 0)’
mdadm-4.3/Manage.c:1817:19: acquire_resource: opened here
mdadm-4.3/Manage.c:1818:19: throw: if ‘open’ throws an exception...
mdadm-4.3/Manage.c:1818:19: danger: ‘open(to_devname, 0)’ leaks here; was opened at [(1)](sarif:/runs/0/results/1/codeFlows/0/threadFlows/0/locations/0)
# 1816|   	/* try to remove and add */
# 1817|   	int fd1 = open(to_devname, O_RDONLY);
# 1818|-> 	int fd2 = open(from_devname, O_RDONLY);
# 1819|   
# 1820|   	if (fd1 < 0 || fd2 < 0) {

Error: GCC_ANALYZER_WARNING (CWE-775): [#def39]
mdadm-4.3/Manage.c:1820:13: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(from_devname, 0)’
mdadm-4.3/Manage.c:1818:19: acquire_resource: opened here
mdadm-4.3/Manage.c:1820:12: branch_true: following ‘true’ branch...
mdadm-4.3/Manage.c:1821:20: branch_true: ...to here
mdadm-4.3/Manage.c:1821:20: branch_true: following ‘true’ branch...
mdadm-4.3/Manage.c:1822:25: branch_true: ...to here
mdadm-4.3/Manage.c:1822:25: throw: if ‘close’ throws an exception...
mdadm-4.3/Manage.c:1820:13: danger: ‘open(from_devname, 0)’ leaks here; was opened at [(1)](sarif:/runs/0/results/3/codeFlows/0/threadFlows/0/locations/0)
# 1818|   	int fd2 = open(from_devname, O_RDONLY);
# 1819|   
# 1820|-> 	if (fd1 < 0 || fd2 < 0) {
# 1821|   		if (fd1 >= 0)
# 1822|   			close(fd1);

Error: GCC_ANALYZER_WARNING (CWE-775): [#def40]
mdadm-4.3/Manage.c:1820:13: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(to_devname, 0)’
mdadm-4.3/Manage.c:1817:19: acquire_resource: opened here
mdadm-4.3/Manage.c:1820:12: branch_true: following ‘true’ branch...
mdadm-4.3/Manage.c:1821:20: branch_true: ...to here
mdadm-4.3/Manage.c:1821:20: branch_true: following ‘true’ branch...
mdadm-4.3/Manage.c:1822:25: branch_true: ...to here
mdadm-4.3/Manage.c:1820:13: danger: ‘open(to_devname, 0)’ leaks here; was opened at [(1)](sarif:/runs/0/results/2/codeFlows/0/threadFlows/0/locations/0)
# 1818|   	int fd2 = open(from_devname, O_RDONLY);
# 1819|   
# 1820|-> 	if (fd1 < 0 || fd2 < 0) {
# 1821|   		if (fd1 >= 0)
# 1822|   			close(fd1);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def41]
mdadm-4.3/Monitor.c:651:13: warning[-Wanalyzer-malloc-leak]: leak of ‘popen("/usr/sbin/sendmail -t", "w")’
mdadm-4.3/Monitor.c:730:12: enter_function: entry to ‘check_array’
mdadm-4.3/Monitor.c:757:12: branch_false: following ‘false’ branch...
mdadm-4.3/Monitor.c:760:13: branch_false: ...to here
mdadm-4.3/Monitor.c:763:29: branch_true: following ‘true’ branch (when ‘mse2’ is non-NULL)...
mdadm-4.3/Monitor.c:764:41: branch_true: ...to here
mdadm-4.3/Monitor.c:764:20: branch_true: following ‘true’ branch (when the strings are equal)...
mdadm-4.3/Monitor.c:765:25: branch_true: ...to here
mdadm-4.3/Monitor.c:769:12: branch_false: following ‘false’ branch (when ‘mse’ is non-NULL)...
mdadm-4.3/Monitor.c:777:13: branch_false: ...to here
mdadm-4.3/Monitor.c:784:12: branch_false: following ‘false’ branch...
mdadm-4.3/Monitor.c:787:12: branch_false: ...to here
mdadm-4.3/Monitor.c:793:12: branch_false: following ‘false’ branch...
mdadm-4.3/Monitor.c:799:13: branch_false: ...to here
mdadm-4.3/Monitor.c:799:12: branch_false: following ‘false’ branch...
mdadm-4.3/Monitor.c:807:13: branch_false: ...to here
mdadm-4.3/Monitor.c:878:12: branch_true: following ‘true’ branch...
mdadm-4.3/Monitor.c:879:13: branch_true: ...to here
mdadm-4.3/Monitor.c:878:13: branch_true: following ‘true’ branch...
mdadm-4.3/Monitor.c:880:13: call_function: inlined call to ‘is_subarray’ from ‘check_array’
mdadm-4.3/Monitor.c:878:13: branch_true: following ‘true’ branch...
mdadm-4.3/Monitor.c:882:17: branch_true: ...to here
mdadm-4.3/Monitor.c:884:20: branch_false: following ‘false’ branch (when ‘sl’ is NULL)...
mdadm-4.3/Monitor.c:888:13: branch_false: ...to here
mdadm-4.3/Monitor.c:891:21: branch_true: following ‘true’ branch (when ‘i != 4096’)...
mdadm-4.3/Monitor.c:897:20: branch_true: ...to here
mdadm-4.3/Monitor.c:907:21: branch_true: following ‘true’ branch...
mdadm-4.3/Monitor.c:909:48: call_function: inlined call to ‘gnu_dev_minor’ from ‘check_array’
mdadm-4.3/Monitor.c:911:20: branch_true: following ‘true’ branch...
mdadm-4.3/Monitor.c:912:28: branch_true: following ‘true’ branch...
mdadm-4.3/Monitor.c:913:33: branch_true: ...to here
mdadm-4.3/Monitor.c:913:33: call_function: calling ‘alert’ from ‘check_array’
#  649|   
#  650|   	signal(SIGPIPE, SIG_IGN);
#  651|-> 	if (info.mailfrom)
#  652|   		fprintf(mp, "From: %s\n", info.mailfrom);
#  653|   	else

Error: GCC_ANALYZER_WARNING (CWE-775): [#def42]
mdadm-4.3/Monitor.c:760:13: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(dev, 0)’
mdadm-4.3/Monitor.c:756:14: acquire_resource: opened here
mdadm-4.3/Monitor.c:757:12: branch_false: following ‘false’ branch...
mdadm-4.3/Monitor.c:760:13: branch_false: ...to here
mdadm-4.3/Monitor.c:760:12: branch_true: following ‘true’ branch...
mdadm-4.3/Monitor.c:761:17: branch_true: ...to here
mdadm-4.3/Monitor.c:761:17: throw: if ‘fd2devnm’ throws an exception...
mdadm-4.3/Monitor.c:760:13: danger: ‘open(dev, 0)’ leaks here; was opened at [(1)](sarif:/runs/0/results/1/codeFlows/0/threadFlows/0/locations/0)
#  758|   		goto disappeared;
#  759|   
#  760|-> 	if (st->devnm[0] == 0)
#  761|   		snprintf(st->devnm, MD_NAME_MAX, "%s", fd2devnm(fd));
#  762|   

Error: GCC_ANALYZER_WARNING (CWE-775): [#def43]
mdadm-4.3/Monitor.c:971:29: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(&*<unknown>.devname, 0)’
mdadm-4.3/Monitor.c:955:28: branch_true: following ‘true’ branch (when ‘mse’ is non-NULL)...
mdadm-4.3/Monitor.c:956:21: branch_true: ...to here
mdadm-4.3/Monitor.c:956:20: branch_true: following ‘true’ branch...
mdadm-4.3/Monitor.c:956:40: branch_true: ...to here
mdadm-4.3/Monitor.c:970:35: acquire_resource: opened here
mdadm-4.3/Monitor.c:970:28: branch_false: following ‘false’ branch...
mdadm-4.3/Monitor.c:971:29: branch_false: ...to here
mdadm-4.3/Monitor.c:971:29: throw: if ‘md_get_array_info’ throws an exception...
mdadm-4.3/Monitor.c:971:29: danger: ‘open(&*<unknown>.devname, 0)’ leaks here; was opened at [(5)](sarif:/runs/0/results/4/codeFlows/0/threadFlows/0/locations/4)
#  969|   			snprintf(st->devname, MD_NAME_MAX + sizeof(DEV_MD_DIR), "%s", name);
#  970|   			if ((fd = open(st->devname, O_RDONLY)) < 0 ||
#  971|-> 			    md_get_array_info(fd, &array) < 0) {
#  972|   				/* no such array */
#  973|   				if (fd >= 0)

Error: GCC_ANALYZER_WARNING (CWE-476): [#def44]
mdadm-4.3/Monitor.c:998:33: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘sl’
mdadm-4.3/Monitor.c:949:12: enter_function: entry to ‘add_new_arrays’
mdadm-4.3/Monitor.c:955:28: branch_true: following ‘true’ branch (when ‘mse’ is non-NULL)...
mdadm-4.3/Monitor.c:956:21: branch_true: ...to here
mdadm-4.3/Monitor.c:956:20: branch_true: following ‘true’ branch...
mdadm-4.3/Monitor.c:956:40: branch_true: ...to here
mdadm-4.3/Monitor.c:970:28: branch_false: following ‘false’ branch...
mdadm-4.3/Monitor.c:971:29: branch_false: ...to here
mdadm-4.3/Monitor.c:970:29: branch_false: following ‘false’ branch...
mdadm-4.3/Monitor.c:983:25: branch_false: ...to here
mdadm-4.3/Monitor.c:990:28: branch_true: following ‘true’ branch...
mdadm-4.3/Monitor.c:991:29: branch_true: ...to here
mdadm-4.3/Monitor.c:990:29: branch_true: following ‘true’ branch...
mdadm-4.3/Monitor.c:993:29: call_function: inlined call to ‘is_subarray’ from ‘add_new_arrays’
mdadm-4.3/Monitor.c:990:29: branch_true: following ‘true’ branch...
mdadm-4.3/Monitor.c:995:33: branch_true: ...to here
mdadm-4.3/Monitor.c:998:33: danger: dereference of NULL ‘sl’
#  996|   					 "%s", mse->metadata_version + 10);
#  997|   				sl = strchr(st->parent_devnm, '/');
#  998|-> 				*sl = 0;
#  999|   			} else
# 1000|   				st->parent_devnm[0] = 0;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def45]
mdadm-4.3/Monitor.c:1023:13: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(&*st.devname, 0)’
mdadm-4.3/Monitor.c:1014:12: branch_false: following ‘false’ branch...
mdadm-4.3/Monitor.c:1020:14: acquire_resource: opened here
mdadm-4.3/Monitor.c:1021:12: branch_false: following ‘false’ branch...
mdadm-4.3/Monitor.c:1023:13: branch_false: ...to here
mdadm-4.3/Monitor.c:1023:12: branch_true: following ‘true’ branch...
mdadm-4.3/Monitor.c:1024:17: branch_true: ...to here
mdadm-4.3/Monitor.c:1024:17: throw: if the called function throws an exception...
mdadm-4.3/Monitor.c:1023:13: danger: ‘open(&*st.devname, 0)’ leaks here; was opened at [(3)](sarif:/runs/0/results/6/codeFlows/0/threadFlows/0/locations/2)
# 1021|   	if (fd < 0)
# 1022|   		return 1;
# 1023|-> 	if (st->metadata->ss->external)
# 1024|   		st->metadata->ss->load_container(st->metadata, fd, st->devname);
# 1025|   	else

Error: GCC_ANALYZER_WARNING (CWE-775): [#def46]
mdadm-4.3/Monitor.c:1117:14: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(&*from.devname, 0)’
mdadm-4.3/Monitor.c:1111:18: acquire_resource: opened here
mdadm-4.3/Monitor.c:1115:12: branch_false: following ‘false’ branch...
mdadm-4.3/Monitor.c:1117:14: branch_false: ...to here
mdadm-4.3/Monitor.c:1117:12: branch_true: following ‘true’ branch...
mdadm-4.3/Monitor.c:1118:17: branch_true: ...to here
mdadm-4.3/Monitor.c:1117:14: danger: ‘open(&*from.devname, 0)’ leaks here; was opened at [(1)](sarif:/runs/0/results/8/codeFlows/0/threadFlows/0/locations/0)
# 1115|   	if (fd < 0)
# 1116|   		return 0;
# 1117|-> 	if (!st->ss->getinfo_super_disks) {
# 1118|   		close(fd);
# 1119|   		return 0;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def47]
mdadm-4.3/Monitor.c:1367:23: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(dev, 0)’
mdadm-4.3/Monitor.c:1358:12: branch_false: following ‘false’ branch...
mdadm-4.3/Monitor.c:1360:14: branch_false: ...to here
mdadm-4.3/Monitor.c:1360:14: acquire_resource: opened here
mdadm-4.3/Monitor.c:1361:12: branch_false: following ‘false’ branch...
mdadm-4.3/Monitor.c:1367:23: branch_false: ...to here
mdadm-4.3/Monitor.c:1367:23: throw: if ‘fd2devnm’ throws an exception...
mdadm-4.3/Monitor.c:1367:23: danger: ‘open(dev, 0)’ leaks here; was opened at [(3)](sarif:/runs/0/results/10/codeFlows/0/threadFlows/0/locations/2)
# 1365|   	}
# 1366|   
# 1367|-> 	strcpy(devnm, fd2devnm(fd));
# 1368|   	mdi = sysfs_read(fd, devnm, GET_VERSION|GET_LEVEL|GET_SAFEMODE);
# 1369|   	if (!mdi) {

Error: GCC_ANALYZER_WARNING (CWE-775): [#def48]
mdadm-4.3/bitmap.c:470:9: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(filename, "w")’
mdadm-4.3/bitmap.c:428:5: enter_function: entry to ‘CreateBitmap’
mdadm-4.3/bitmap.c:449:14: acquire_resource: opened here
mdadm-4.3/bitmap.c:450:12: branch_false: following ‘false’ branch...
mdadm-4.3/bitmap.c:456:12: branch_false: ...to here
mdadm-4.3/bitmap.c:471:12: branch_false: following ‘false’ branch (when ‘uuid’ is NULL)...
mdadm-4.3/bitmap.c:473:9: branch_false: ...to here
mdadm-4.3/bitmap.c:480:12: branch_false: following ‘false’ branch...
mdadm-4.3/bitmap.c:486:18: call_function: inlined call to ‘bitmap_bits’ from ‘CreateBitmap’
mdadm-4.3/bitmap.c:487:12: branch_false: following ‘false’ branch...
mdadm-4.3/bitmap.c:492:20: branch_false: ...to here
mdadm-4.3/bitmap.c:505:9: throw: if ‘fflush’ throws an exception...
mdadm-4.3/bitmap.c:470:9: danger: ‘fopen(filename, "w")’ leaks here; was opened at [(2)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/1)
#  468|   	memset(&sb, 0, sizeof(sb));
#  469|   	sb.magic = BITMAP_MAGIC;
#  470|-> 	sb.version = major;
#  471|   	if (uuid != NULL)
#  472|   		memcpy(sb.uuid, uuid, 16);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def49]
mdadm-4.3/bitmap.c:470:9: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(filename, "w")’
mdadm-4.3/bitmap.c:428:5: enter_function: entry to ‘CreateBitmap’
mdadm-4.3/bitmap.c:449:14: acquire_memory: allocated here
mdadm-4.3/bitmap.c:450:12: branch_false: following ‘false’ branch...
mdadm-4.3/bitmap.c:456:12: branch_false: ...to here
mdadm-4.3/bitmap.c:471:12: branch_false: following ‘false’ branch (when ‘uuid’ is NULL)...
mdadm-4.3/bitmap.c:473:9: branch_false: ...to here
mdadm-4.3/bitmap.c:480:12: branch_false: following ‘false’ branch...
mdadm-4.3/bitmap.c:486:18: call_function: inlined call to ‘bitmap_bits’ from ‘CreateBitmap’
mdadm-4.3/bitmap.c:487:12: branch_false: following ‘false’ branch...
mdadm-4.3/bitmap.c:492:20: branch_false: ...to here
mdadm-4.3/bitmap.c:505:9: throw: if ‘fflush’ throws an exception...
mdadm-4.3/bitmap.c:470:9: danger: ‘fopen(filename, "w")’ leaks here; was allocated at [(2)](sarif:/runs/0/results/1/codeFlows/0/threadFlows/0/locations/1)
#  468|   	memset(&sb, 0, sizeof(sb));
#  469|   	sb.magic = BITMAP_MAGIC;
#  470|-> 	sb.version = major;
#  471|   	if (uuid != NULL)
#  472|   		memcpy(sb.uuid, uuid, 16);

Error: GCC_ANALYZER_WARNING (CWE-775): [#def50]
mdadm-4.3/config.c:870:24: warning[-Wanalyzer-file-leak]: leak of FILE ‘f’
mdadm-4.3/config.c:979:6: enter_function: entry to ‘load_conffile’
mdadm-4.3/config.c:987:12: branch_false: following ‘false’ branch...
mdadm-4.3/config.c:992:13: branch_false: ...to here
mdadm-4.3/config.c:992:12: branch_false: following ‘false’ branch (when the strings are non-equal)...
mdadm-4.3/config.c:998:20: branch_false: ...to here
mdadm-4.3/config.c:998:19: branch_false: following ‘false’ branch...
mdadm-4.3/config.c:999:21: branch_false: ...to here
mdadm-4.3/config.c:999:21: acquire_resource: opened here
mdadm-4.3/config.c:1005:20: branch_false: following ‘false’ branch...
mdadm-4.3/config.c:1013:25: branch_false: ...to here
mdadm-4.3/config.c:1013:25: call_function: calling ‘conf_file_or_dir’ from ‘load_conffile’
#  868|   {
#  869|   	char *line;
#  870|-> 	while ((line = conf_line(f))) {
#  871|   		switch(match_keyword(line)) {
#  872|   		case Devices:

Error: GCC_ANALYZER_WARNING (CWE-401): [#def51]
mdadm-4.3/config.c:870:24: warning[-Wanalyzer-malloc-leak]: leak of ‘f2’
mdadm-4.3/config.c:979:6: enter_function: entry to ‘load_conffile’
mdadm-4.3/config.c:987:12: branch_false: following ‘false’ branch...
mdadm-4.3/config.c:992:13: branch_false: ...to here
mdadm-4.3/config.c:992:12: branch_false: following ‘false’ branch (when the strings are non-equal)...
mdadm-4.3/config.c:998:20: branch_false: ...to here
mdadm-4.3/config.c:998:19: branch_false: following ‘false’ branch...
mdadm-4.3/config.c:999:21: branch_false: ...to here
mdadm-4.3/config.c:1005:20: branch_false: following ‘false’ branch...
mdadm-4.3/config.c:1013:25: branch_false: ...to here
mdadm-4.3/config.c:1013:25: call_function: calling ‘conf_file_or_dir’ from ‘load_conffile’
#  868|   {
#  869|   	char *line;
#  870|-> 	while ((line = conf_line(f))) {
#  871|   		switch(match_keyword(line)) {
#  872|   		case Devices:

Error: GCC_ANALYZER_WARNING (CWE-401): [#def52]
mdadm-4.3/config.c:870:24: warning[-Wanalyzer-malloc-leak]: leak of ‘f’
mdadm-4.3/config.c:979:6: enter_function: entry to ‘load_conffile’
mdadm-4.3/config.c:987:12: branch_false: following ‘false’ branch...
mdadm-4.3/config.c:992:13: branch_false: ...to here
mdadm-4.3/config.c:992:12: branch_false: following ‘false’ branch (when the strings are non-equal)...
mdadm-4.3/config.c:998:20: branch_false: ...to here
mdadm-4.3/config.c:998:19: branch_false: following ‘false’ branch...
mdadm-4.3/config.c:999:21: branch_false: ...to here
mdadm-4.3/config.c:999:21: acquire_memory: allocated here
mdadm-4.3/config.c:1005:20: branch_false: following ‘false’ branch...
mdadm-4.3/config.c:1013:25: branch_false: ...to here
mdadm-4.3/config.c:1013:25: call_function: calling ‘conf_file_or_dir’ from ‘load_conffile’
#  868|   {
#  869|   	char *line;
#  870|-> 	while ((line = conf_line(f))) {
#  871|   		switch(match_keyword(line)) {
#  872|   		case Devices:

Error: GCC_ANALYZER_WARNING (CWE-401): [#def53]
mdadm-4.3/config.c:939:22: warning[-Wanalyzer-malloc-leak]: leak of ‘fdopendir(fileno(f))’
mdadm-4.3/config.c:979:6: enter_function: entry to ‘load_conffile’
mdadm-4.3/config.c:987:12: branch_false: following ‘false’ branch...
mdadm-4.3/config.c:992:13: branch_false: ...to here
mdadm-4.3/config.c:992:12: branch_false: following ‘false’ branch (when the strings are non-equal)...
mdadm-4.3/config.c:998:20: branch_false: ...to here
mdadm-4.3/config.c:998:19: branch_false: following ‘false’ branch...
mdadm-4.3/config.c:999:21: branch_false: ...to here
mdadm-4.3/config.c:1005:20: branch_false: following ‘false’ branch...
mdadm-4.3/config.c:1013:25: branch_false: ...to here
mdadm-4.3/config.c:1013:25: call_function: calling ‘conf_file_or_dir’ from ‘load_conffile’
#  937|   	if (!dir)
#  938|   		return;
#  939|-> 	while ((dp = readdir(dir)) != NULL) {
#  940|   		int l;
#  941|   		struct fname *fn, **p;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def54]
mdadm-4.3/lib.c:343:22: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen("/proc/devices", "r")’
mdadm-4.3/lib.c:63:5: enter_function: entry to ‘get_mdp_major’
mdadm-4.3/lib.c:75:14: acquire_resource: opened here
mdadm-4.3/lib.c:76:12: branch_false: following ‘false’ branch...
mdadm-4.3/lib.c:76:12: branch_false: ...to here
mdadm-4.3/lib.c:79:21: call_function: calling ‘conf_word’ from ‘get_mdp_major’
#  341|   	int quote;
#  342|   	int wordfound = 0;
#  343|-> 	char *word = xmalloc(wsize);
#  344|   
#  345|   	while (wordfound == 0) {

Error: GCC_ANALYZER_WARNING (CWE-401): [#def55]
mdadm-4.3/lib.c:343:22: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen("/proc/devices", "r")’
mdadm-4.3/lib.c:63:5: enter_function: entry to ‘get_mdp_major’
mdadm-4.3/lib.c:75:14: acquire_memory: allocated here
mdadm-4.3/lib.c:76:12: branch_false: following ‘false’ branch...
mdadm-4.3/lib.c:76:12: branch_false: ...to here
mdadm-4.3/lib.c:79:21: call_function: calling ‘conf_word’ from ‘get_mdp_major’
#  341|   	int quote;
#  342|   	int wordfound = 0;
#  343|-> 	char *word = xmalloc(wsize);
#  344|   
#  345|   	while (wordfound == 0) {

Error: GCC_ANALYZER_WARNING (CWE-775): [#def56]
mdadm-4.3/lib.c:356:21: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen("/proc/devices", "r")’
mdadm-4.3/lib.c:63:5: enter_function: entry to ‘get_mdp_major’
mdadm-4.3/lib.c:75:14: acquire_resource: opened here
mdadm-4.3/lib.c:76:12: branch_false: following ‘false’ branch...
mdadm-4.3/lib.c:76:12: branch_false: ...to here
mdadm-4.3/lib.c:79:21: call_function: calling ‘conf_word’ from ‘get_mdp_major’
#  354|   			continue;
#  355|   
#  356|-> 		if (c != ' ' && c != '\t' && ! allow_key) {
#  357|   			ungetc(c, file);
#  358|   			break;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def57]
mdadm-4.3/lib.c:356:21: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen("/proc/devices", "r")’
mdadm-4.3/lib.c:63:5: enter_function: entry to ‘get_mdp_major’
mdadm-4.3/lib.c:75:14: acquire_memory: allocated here
mdadm-4.3/lib.c:76:12: branch_false: following ‘false’ branch...
mdadm-4.3/lib.c:76:12: branch_false: ...to here
mdadm-4.3/lib.c:79:21: call_function: calling ‘conf_word’ from ‘get_mdp_major’
#  354|   			continue;
#  355|   
#  356|-> 		if (c != ' ' && c != '\t' && ! allow_key) {
#  357|   			ungetc(c, file);
#  358|   			break;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def58]
mdadm-4.3/mapfile.c:67:14: warning[-Wanalyzer-malloc-leak]: leak of ‘open_map(1)’
mdadm-4.3/mapfile.c:356:6: enter_function: entry to ‘RebuildMap’
mdadm-4.3/mapfile.c:504:13: call_function: calling ‘map_write’ from ‘RebuildMap’
#   65|   {
#   66|   	int fd;
#   67|-> 	if ((mapmode[modenum] & O_CREAT))
#   68|   		/* Attempt to create directory, don't worry about
#   69|   		 * failure.

Error: GCC_ANALYZER_WARNING (CWE-775): [#def59]
mdadm-4.3/mdadm.c:1060:30: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(optarg, 2)’
mdadm-4.3/mdadm.c:110:12: branch_false: following ‘false’ branch...
mdadm-4.3/mdadm.c:115:9: branch_false: ...to here
mdadm-4.3/mdadm.c:117:16: branch_true: following ‘true’ branch (when ‘opt != -1’)...
mdadm-4.3/mdadm.c:122:17: branch_true: ...to here
mdadm-4.3/mdadm.c:261:20: branch_false: following ‘false’ branch...
mdadm-4.3/mdadm.c:263:36: branch_false: ...to here
mdadm-4.3/mdadm.c:263:27: branch_false: following ‘false’ branch...
mdadm-4.3/mdadm.c:274:28: branch_false: ...to here
mdadm-4.3/mdadm.c:274:27: branch_true: following ‘true’ branch...
mdadm-4.3/mdadm.c:276:29: branch_true: ...to here
mdadm-4.3/mdadm.c:276:28: branch_false: following ‘false’ branch...
mdadm-4.3/mdadm.c:321:17: branch_false: ...to here
mdadm-4.3/mdadm.c:333:20: branch_false: following ‘false’ branch (when ‘opt != 1’)...
mdadm-4.3/mdadm.c:368:25: branch_false: ...to here
mdadm-4.3/mdadm.c:1049:28: branch_false: following ‘false’ branch...
mdadm-4.3/mdadm.c:1053:29: branch_false: ...to here
mdadm-4.3/mdadm.c:1053:28: branch_false: following ‘false’ branch (when the strings are non-equal)...
mdadm-4.3/mdadm.c:1054:29: branch_false: ...to here
mdadm-4.3/mdadm.c:1053:29: branch_false: following ‘false’ branch (when the strings are non-equal)...
mdadm-4.3/mdadm.c:1059:37: branch_false: ...to here
mdadm-4.3/mdadm.c:1059:37: acquire_resource: opened here
mdadm-4.3/mdadm.c:1060:30: danger: ‘open(optarg, 2)’ leaks here; was opened at [(27)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/26)
# 1058|   			}
# 1059|   			bitmap_fd = open(optarg, O_RDWR);
# 1060|-> 			if (!*optarg || bitmap_fd < 0) {
# 1061|   				pr_err("cannot open bitmap file %s: %s\n", optarg, strerror(errno));
# 1062|   				exit(2);

Error: GCC_ANALYZER_WARNING (CWE-775): [#def60]
mdadm-4.3/mdadm.c:1981:18: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(dev, 0)’
mdadm-4.3/mdadm.c:1973:18: acquire_resource: opened here
mdadm-4.3/mdadm.c:1977:12: branch_false: following ‘false’ branch...
mdadm-4.3/mdadm.c:1981:18: branch_false: ...to here
mdadm-4.3/mdadm.c:1981:18: throw: if ‘sysfs_init’ throws an exception...
mdadm-4.3/mdadm.c:1981:18: danger: ‘open(dev, 0)’ leaks here; was opened at [(1)](sarif:/runs/0/results/1/codeFlows/0/threadFlows/0/locations/0)
# 1979|   		return 1;
# 1980|   	}
# 1981|-> 	retval = sysfs_init(&mdi, fd, NULL);
# 1982|   	close(fd);
# 1983|   	if (retval) {

Error: GCC_ANALYZER_WARNING (CWE-775): [#def61]
mdadm-4.3/mdadm.h:1365:16: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(dev,  <unknown>)’
mdadm-4.3/Kill.c:32:5: enter_function: entry to ‘Kill’
mdadm-4.3/Kill.c:49:14: acquire_resource: opened here
mdadm-4.3/Kill.c:50:12: branch_false: following ‘false’ branch...
mdadm-4.3/Kill.c:56:12: branch_false: ...to here
mdadm-4.3/Kill.c:56:12: branch_true: following ‘true’ branch (when ‘st’ is NULL)...
mdadm-4.3/Kill.c:57:22: call_function: inlined call to ‘guess_super’ from ‘Kill’
# 1363|   extern struct supertype *guess_super_type(int fd, enum guess_types guess_type);
# 1364|   static inline struct supertype *guess_super(int fd) {
# 1365|-> 	return guess_super_type(fd, guess_any);
# 1366|   }
# 1367|   extern struct supertype *dup_super(struct supertype *st);

Error: GCC_ANALYZER_WARNING (CWE-775): [#def62]
mdadm-4.3/mdmon.c:187:9: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(&buf, 0)’
mdadm-4.3/mdmon.c:176:12: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:180:9: branch_false: ...to here
mdadm-4.3/mdmon.c:181:14: acquire_resource: opened here
mdadm-4.3/mdmon.c:182:12: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:185:13: branch_false: ...to here
mdadm-4.3/mdmon.c:187:9: danger: ‘open(&buf, 0)’ leaks here; was opened at [(3)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/2)
#  185|   	n = read(fd, buf, sizeof(buf)-1);
#  186|   	buf[sizeof(buf)-1] = 0;
#  187|-> 	close(fd);
#  188|   
#  189|   	if (n < 0 || !(strstr(buf, "mdmon") ||

Error: GCC_ANALYZER_WARNING (CWE-775): [#def63]
mdadm-4.3/mdmon.c:250:14: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘sfd’
mdadm-4.3/mdmon.c:233:12: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:236:9: branch_false: ...to here
mdadm-4.3/mdmon.c:238:15: acquire_resource: stream socket created here
mdadm-4.3/mdmon.c:239:12: branch_false: following ‘false’ branch (when ‘sfd >= 0’)...
mdadm-4.3/mdmon.c:242:9: branch_false: ...to here
mdadm-4.3/mdmon.c:245:12: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:249:9: branch_false: ...to here
mdadm-4.3/mdmon.c:250:14: throw: if ‘fcntl’ throws an exception...
mdadm-4.3/mdmon.c:250:14: danger: ‘sfd’ leaks here
#  248|   	}
#  249|   	listen(sfd, 10);
#  250|-> 	fl = fcntl(sfd, F_GETFL, 0);
#  251|   	fl |= O_NONBLOCK;
#  252|   	fcntl(sfd, F_SETFL, fl);

Error: GCC_ANALYZER_WARNING (CWE-775): [#def64]
mdadm-4.3/mdmon.c:446:24: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘pfd[0]’
mdadm-4.3/mdmon.c:444:12: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:450:12: branch_false: ...to here
mdadm-4.3/mdmon.c:450:12: branch_true: following ‘true’ branch (when ‘must_fork != 0’)...
mdadm-4.3/mdmon.c:451:21: branch_true: ...to here
mdadm-4.3/mdmon.c:451:20: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:455:24: branch_false: ...to here
mdadm-4.3/mdmon.c:446:24: danger: ‘pfd[0]’ leaks here
#  444|   	if (mdfd < 0) {
#  445|   		pr_err("%s: %s\n", devnm, strerror(errno));
#  446|-> 		return 1;
#  447|   	}
#  448|   

Error: GCC_ANALYZER_WARNING (CWE-775): [#def65]
mdadm-4.3/mdmon.c:446:24: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘pfd[1]’
mdadm-4.3/mdmon.c:444:12: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:450:12: branch_false: ...to here
mdadm-4.3/mdmon.c:450:12: branch_true: following ‘true’ branch (when ‘must_fork != 0’)...
mdadm-4.3/mdmon.c:451:21: branch_true: ...to here
mdadm-4.3/mdmon.c:451:20: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:455:24: branch_false: ...to here
mdadm-4.3/mdmon.c:446:24: danger: ‘pfd[1]’ leaks here
#  444|   	if (mdfd < 0) {
#  445|   		pr_err("%s: %s\n", devnm, strerror(errno));
#  446|-> 		return 1;
#  447|   	}
#  448|   

Error: GCC_ANALYZER_WARNING (CWE-775): [#def66]
mdadm-4.3/mdmon.c:446:24: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘pfd[status]’
mdadm-4.3/mdmon.c:302:5: enter_function: entry to ‘main’
mdadm-4.3/mdmon.c:327:16: branch_true: following ‘true’ branch (when ‘opt != -1’)...
mdadm-4.3/mdmon.c:328:17: branch_true: ...to here
mdadm-4.3/mdmon.c:330:29: call_function: inlined call to ‘is_duplicate_opt’ from ‘main’
mdadm-4.3/mdmon.c:332:46: branch_false: ...to here
mdadm-4.3/mdmon.c:370:12: branch_false: following ‘false’ branch (when ‘all != 0’)...
mdadm-4.3/mdmon.c:381:12: branch_false: ...to here
mdadm-4.3/mdmon.c:381:12: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:387:12: branch_false: following ‘false’ branch (when ‘help == 0’)...
mdadm-4.3/mdmon.c:390:12: branch_false: ...to here
mdadm-4.3/mdmon.c:390:12: branch_true: following ‘true’ branch (when ‘all != 0’)...
mdadm-4.3/mdmon.c:392:37: branch_true: ...to here
mdadm-4.3/mdmon.c:396:34: branch_true: following ‘true’ branch (when ‘e’ is non-NULL)...
mdadm-4.3/mdmon.c:397:29: branch_true: ...to here
mdadm-4.3/mdmon.c:397:28: branch_true: following ‘true’ branch...
mdadm-4.3/mdmon.c:398:29: branch_true: ...to here
mdadm-4.3/mdmon.c:397:29: branch_true: following ‘true’ branch...
mdadm-4.3/mdmon.c:399:30: call_function: inlined call to ‘is_subarray’ from ‘main’
mdadm-4.3/mdmon.c:397:29: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:403:44: branch_false: ...to here
mdadm-4.3/mdmon.c:407:43: call_function: calling ‘mdmon’ from ‘main’
#  444|   	if (mdfd < 0) {
#  445|   		pr_err("%s: %s\n", devnm, strerror(errno));
#  446|-> 		return 1;
#  447|   	}
#  448|   

Error: GCC_ANALYZER_WARNING (CWE-775): [#def67]
mdadm-4.3/mdmon.c:460:25: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘pfd[0]’
mdadm-4.3/mdmon.c:444:12: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:450:12: branch_false: ...to here
mdadm-4.3/mdmon.c:450:12: branch_true: following ‘true’ branch (when ‘must_fork != 0’)...
mdadm-4.3/mdmon.c:451:21: branch_true: ...to here
mdadm-4.3/mdmon.c:451:20: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:455:24: branch_false: ...to here
mdadm-4.3/mdmon.c:460:25: throw: if ‘close’ throws an exception...
mdadm-4.3/mdmon.c:460:25: danger: ‘pfd[0]’ leaks here
#  458|   			return 1;
#  459|   		case 0: /* child */
#  460|-> 			close(pfd[0]);
#  461|   			break;
#  462|   		default: /* parent */

Error: GCC_ANALYZER_WARNING (CWE-775): [#def68]
mdadm-4.3/mdmon.c:460:25: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘pfd[1]’
mdadm-4.3/mdmon.c:444:12: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:450:12: branch_false: ...to here
mdadm-4.3/mdmon.c:450:12: branch_true: following ‘true’ branch (when ‘must_fork != 0’)...
mdadm-4.3/mdmon.c:451:21: branch_true: ...to here
mdadm-4.3/mdmon.c:451:20: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:455:24: branch_false: ...to here
mdadm-4.3/mdmon.c:460:25: throw: if ‘close’ throws an exception...
mdadm-4.3/mdmon.c:460:25: danger: ‘pfd[1]’ leaks here
#  458|   			return 1;
#  459|   		case 0: /* child */
#  460|-> 			close(pfd[0]);
#  461|   			break;
#  462|   		default: /* parent */

Error: GCC_ANALYZER_WARNING (CWE-775): [#def69]
mdadm-4.3/mdmon.c:460:25: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘pfd[status]’
mdadm-4.3/mdmon.c:302:5: enter_function: entry to ‘main’
mdadm-4.3/mdmon.c:327:16: branch_true: following ‘true’ branch (when ‘opt != -1’)...
mdadm-4.3/mdmon.c:328:17: branch_true: ...to here
mdadm-4.3/mdmon.c:330:29: call_function: inlined call to ‘is_duplicate_opt’ from ‘main’
mdadm-4.3/mdmon.c:332:46: branch_false: ...to here
mdadm-4.3/mdmon.c:370:12: branch_false: following ‘false’ branch (when ‘all != 0’)...
mdadm-4.3/mdmon.c:381:12: branch_false: ...to here
mdadm-4.3/mdmon.c:381:12: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:387:12: branch_false: following ‘false’ branch (when ‘help == 0’)...
mdadm-4.3/mdmon.c:390:12: branch_false: ...to here
mdadm-4.3/mdmon.c:390:12: branch_true: following ‘true’ branch (when ‘all != 0’)...
mdadm-4.3/mdmon.c:392:37: branch_true: ...to here
mdadm-4.3/mdmon.c:396:34: branch_true: following ‘true’ branch (when ‘e’ is non-NULL)...
mdadm-4.3/mdmon.c:397:29: branch_true: ...to here
mdadm-4.3/mdmon.c:397:28: branch_true: following ‘true’ branch...
mdadm-4.3/mdmon.c:398:29: branch_true: ...to here
mdadm-4.3/mdmon.c:397:29: branch_true: following ‘true’ branch...
mdadm-4.3/mdmon.c:399:30: call_function: inlined call to ‘is_subarray’ from ‘main’
mdadm-4.3/mdmon.c:397:29: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:403:44: branch_false: ...to here
mdadm-4.3/mdmon.c:407:43: call_function: calling ‘mdmon’ from ‘main’
#  458|   			return 1;
#  459|   		case 0: /* child */
#  460|-> 			close(pfd[0]);
#  461|   			break;
#  462|   		default: /* parent */

Error: GCC_ANALYZER_WARNING (CWE-775): [#def70]
mdadm-4.3/mdmon.c:463:25: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘pfd[0]’
mdadm-4.3/mdmon.c:444:12: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:450:12: branch_false: ...to here
mdadm-4.3/mdmon.c:450:12: branch_true: following ‘true’ branch (when ‘must_fork != 0’)...
mdadm-4.3/mdmon.c:451:21: branch_true: ...to here
mdadm-4.3/mdmon.c:451:20: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:455:24: branch_false: ...to here
mdadm-4.3/mdmon.c:463:25: throw: if ‘close’ throws an exception...
mdadm-4.3/mdmon.c:463:25: danger: ‘pfd[0]’ leaks here
#  461|   			break;
#  462|   		default: /* parent */
#  463|-> 			close(pfd[1]);
#  464|   			if (read(pfd[0], &status, sizeof(status)) != sizeof(status)) {
#  465|   				wait(&status);

Error: GCC_ANALYZER_WARNING (CWE-775): [#def71]
mdadm-4.3/mdmon.c:463:25: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘pfd[1]’
mdadm-4.3/mdmon.c:444:12: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:450:12: branch_false: ...to here
mdadm-4.3/mdmon.c:450:12: branch_true: following ‘true’ branch (when ‘must_fork != 0’)...
mdadm-4.3/mdmon.c:451:21: branch_true: ...to here
mdadm-4.3/mdmon.c:451:20: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:455:24: branch_false: ...to here
mdadm-4.3/mdmon.c:463:25: throw: if ‘close’ throws an exception...
mdadm-4.3/mdmon.c:463:25: danger: ‘pfd[1]’ leaks here
#  461|   			break;
#  462|   		default: /* parent */
#  463|-> 			close(pfd[1]);
#  464|   			if (read(pfd[0], &status, sizeof(status)) != sizeof(status)) {
#  465|   				wait(&status);

Error: GCC_ANALYZER_WARNING (CWE-775): [#def72]
mdadm-4.3/mdmon.c:463:25: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘pfd[status]’
mdadm-4.3/mdmon.c:302:5: enter_function: entry to ‘main’
mdadm-4.3/mdmon.c:327:16: branch_true: following ‘true’ branch (when ‘opt != -1’)...
mdadm-4.3/mdmon.c:328:17: branch_true: ...to here
mdadm-4.3/mdmon.c:330:29: call_function: inlined call to ‘is_duplicate_opt’ from ‘main’
mdadm-4.3/mdmon.c:332:46: branch_false: ...to here
mdadm-4.3/mdmon.c:370:12: branch_false: following ‘false’ branch (when ‘all != 0’)...
mdadm-4.3/mdmon.c:381:12: branch_false: ...to here
mdadm-4.3/mdmon.c:381:12: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:387:12: branch_false: following ‘false’ branch (when ‘help == 0’)...
mdadm-4.3/mdmon.c:390:12: branch_false: ...to here
mdadm-4.3/mdmon.c:390:12: branch_true: following ‘true’ branch (when ‘all != 0’)...
mdadm-4.3/mdmon.c:392:37: branch_true: ...to here
mdadm-4.3/mdmon.c:396:34: branch_true: following ‘true’ branch (when ‘e’ is non-NULL)...
mdadm-4.3/mdmon.c:397:29: branch_true: ...to here
mdadm-4.3/mdmon.c:397:28: branch_true: following ‘true’ branch...
mdadm-4.3/mdmon.c:398:29: branch_true: ...to here
mdadm-4.3/mdmon.c:397:29: branch_true: following ‘true’ branch...
mdadm-4.3/mdmon.c:399:30: call_function: inlined call to ‘is_subarray’ from ‘main’
mdadm-4.3/mdmon.c:397:29: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:403:44: branch_false: ...to here
mdadm-4.3/mdmon.c:407:43: call_function: calling ‘mdmon’ from ‘main’
#  461|   			break;
#  462|   		default: /* parent */
#  463|-> 			close(pfd[1]);
#  464|   			if (read(pfd[0], &status, sizeof(status)) != sizeof(status)) {
#  465|   				wait(&status);

Error: GCC_ANALYZER_WARNING (CWE-775): [#def73]
mdadm-4.3/mdmon.c:465:33: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘pfd[0]’
mdadm-4.3/mdmon.c:444:12: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:450:12: branch_false: ...to here
mdadm-4.3/mdmon.c:450:12: branch_true: following ‘true’ branch (when ‘must_fork != 0’)...
mdadm-4.3/mdmon.c:451:21: branch_true: ...to here
mdadm-4.3/mdmon.c:451:20: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:455:24: branch_false: ...to here
mdadm-4.3/mdmon.c:464:28: branch_true: following ‘true’ branch...
mdadm-4.3/mdmon.c:465:33: branch_true: ...to here
mdadm-4.3/mdmon.c:465:33: throw: if ‘wait’ throws an exception...
mdadm-4.3/mdmon.c:465:33: danger: ‘pfd[0]’ leaks here
#  463|   			close(pfd[1]);
#  464|   			if (read(pfd[0], &status, sizeof(status)) != sizeof(status)) {
#  465|-> 				wait(&status);
#  466|   				status = WEXITSTATUS(status);
#  467|   			}

Error: GCC_ANALYZER_WARNING (CWE-775): [#def74]
mdadm-4.3/mdmon.c:465:33: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘pfd[status]’
mdadm-4.3/mdmon.c:302:5: enter_function: entry to ‘main’
mdadm-4.3/mdmon.c:327:16: branch_true: following ‘true’ branch (when ‘opt != -1’)...
mdadm-4.3/mdmon.c:328:17: branch_true: ...to here
mdadm-4.3/mdmon.c:330:29: call_function: inlined call to ‘is_duplicate_opt’ from ‘main’
mdadm-4.3/mdmon.c:332:46: branch_false: ...to here
mdadm-4.3/mdmon.c:370:12: branch_false: following ‘false’ branch (when ‘all != 0’)...
mdadm-4.3/mdmon.c:381:12: branch_false: ...to here
mdadm-4.3/mdmon.c:381:12: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:387:12: branch_false: following ‘false’ branch (when ‘help == 0’)...
mdadm-4.3/mdmon.c:390:12: branch_false: ...to here
mdadm-4.3/mdmon.c:390:12: branch_true: following ‘true’ branch (when ‘all != 0’)...
mdadm-4.3/mdmon.c:392:37: branch_true: ...to here
mdadm-4.3/mdmon.c:396:34: branch_true: following ‘true’ branch (when ‘e’ is non-NULL)...
mdadm-4.3/mdmon.c:397:29: branch_true: ...to here
mdadm-4.3/mdmon.c:397:28: branch_true: following ‘true’ branch...
mdadm-4.3/mdmon.c:398:29: branch_true: ...to here
mdadm-4.3/mdmon.c:397:29: branch_true: following ‘true’ branch...
mdadm-4.3/mdmon.c:399:30: call_function: inlined call to ‘is_subarray’ from ‘main’
mdadm-4.3/mdmon.c:397:29: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:403:44: branch_false: ...to here
mdadm-4.3/mdmon.c:407:43: call_function: calling ‘mdmon’ from ‘main’
#  463|   			close(pfd[1]);
#  464|   			if (read(pfd[0], &status, sizeof(status)) != sizeof(status)) {
#  465|-> 				wait(&status);
#  466|   				status = WEXITSTATUS(status);
#  467|   			}

Error: GCC_ANALYZER_WARNING (CWE-775): [#def75]
mdadm-4.3/mdmon.c:468:25: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘pfd[0]’
mdadm-4.3/mdmon.c:444:12: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:450:12: branch_false: ...to here
mdadm-4.3/mdmon.c:450:12: branch_true: following ‘true’ branch (when ‘must_fork != 0’)...
mdadm-4.3/mdmon.c:451:21: branch_true: ...to here
mdadm-4.3/mdmon.c:451:20: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:455:24: branch_false: ...to here
mdadm-4.3/mdmon.c:468:25: throw: if ‘close’ throws an exception...
mdadm-4.3/mdmon.c:468:25: danger: ‘pfd[0]’ leaks here
#  466|   				status = WEXITSTATUS(status);
#  467|   			}
#  468|-> 			close(pfd[0]);
#  469|   			return status;
#  470|   		}

Error: GCC_ANALYZER_WARNING (CWE-775): [#def76]
mdadm-4.3/mdmon.c:468:25: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘pfd[status]’
mdadm-4.3/mdmon.c:302:5: enter_function: entry to ‘main’
mdadm-4.3/mdmon.c:327:16: branch_true: following ‘true’ branch (when ‘opt != -1’)...
mdadm-4.3/mdmon.c:328:17: branch_true: ...to here
mdadm-4.3/mdmon.c:330:29: call_function: inlined call to ‘is_duplicate_opt’ from ‘main’
mdadm-4.3/mdmon.c:332:46: branch_false: ...to here
mdadm-4.3/mdmon.c:370:12: branch_false: following ‘false’ branch (when ‘all != 0’)...
mdadm-4.3/mdmon.c:381:12: branch_false: ...to here
mdadm-4.3/mdmon.c:381:12: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:387:12: branch_false: following ‘false’ branch (when ‘help == 0’)...
mdadm-4.3/mdmon.c:390:12: branch_false: ...to here
mdadm-4.3/mdmon.c:390:12: branch_true: following ‘true’ branch (when ‘all != 0’)...
mdadm-4.3/mdmon.c:392:37: branch_true: ...to here
mdadm-4.3/mdmon.c:396:34: branch_true: following ‘true’ branch (when ‘e’ is non-NULL)...
mdadm-4.3/mdmon.c:397:29: branch_true: ...to here
mdadm-4.3/mdmon.c:397:28: branch_true: following ‘true’ branch...
mdadm-4.3/mdmon.c:398:29: branch_true: ...to here
mdadm-4.3/mdmon.c:397:29: branch_true: following ‘true’ branch...
mdadm-4.3/mdmon.c:399:30: call_function: inlined call to ‘is_subarray’ from ‘main’
mdadm-4.3/mdmon.c:397:29: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:403:44: branch_false: ...to here
mdadm-4.3/mdmon.c:407:43: call_function: calling ‘mdmon’ from ‘main’
#  466|   				status = WEXITSTATUS(status);
#  467|   			}
#  468|-> 			close(pfd[0]);
#  469|   			return status;
#  470|   		}

Error: GCC_ANALYZER_WARNING (CWE-775): [#def77]
mdadm-4.3/mdmon.c:474:21: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘pfd[1]’
mdadm-4.3/mdmon.c:444:12: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:450:12: branch_false: ...to here
mdadm-4.3/mdmon.c:450:12: branch_true: following ‘true’ branch (when ‘must_fork != 0’)...
mdadm-4.3/mdmon.c:451:21: branch_true: ...to here
mdadm-4.3/mdmon.c:451:20: branch_false: following ‘false’ branch...
mdadm-4.3/mdmon.c:455:24: branch_false: ...to here
mdadm-4.3/mdmon.c:474:21: throw: if ‘xcalloc’ throws an exception...
mdadm-4.3/mdmon.c:474:21: danger: ‘pfd[1]’ leaks here
#  472|   		pfd[0] = pfd[1] = -1;
#  473|   
#  474|-> 	container = xcalloc(1, sizeof(*container));
#  475|   	snprintf(container->devnm, MD_NAME_MAX, "%s", devnm);
#  476|   	container->arrays = NULL;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def78]
mdadm-4.3/mdopen.c:120:21: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘fd’
mdadm-4.3/mdopen.c:114:14: acquire_resource: opened here
mdadm-4.3/mdopen.c:115:12: branch_false: following ‘false’ branch...
mdadm-4.3/mdopen.c:120:21: branch_false: ...to here
mdadm-4.3/mdopen.c:120:21: throw: if ‘write’ throws an exception...
mdadm-4.3/mdopen.c:120:21: danger: ‘fd’ leaks here; was opened at [(1)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/0)
#  118|   	}
#  119|   	if (fd >= 0) {
#  120|-> 		n = write(fd, devnm, strlen(devnm));
#  121|   		close(fd);
#  122|   	}

Error: GCC_ANALYZER_WARNING (CWE-775): [#def79]
mdadm-4.3/mdopen.c:121:17: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘fd’
mdadm-4.3/mdopen.c:114:14: acquire_resource: opened here
mdadm-4.3/mdopen.c:115:12: branch_false: following ‘false’ branch...
mdadm-4.3/mdopen.c:120:21: branch_false: ...to here
mdadm-4.3/mdopen.c:121:17: throw: if ‘close’ throws an exception...
mdadm-4.3/mdopen.c:121:17: danger: ‘fd’ leaks here; was opened at [(1)](sarif:/runs/0/results/2/codeFlows/0/threadFlows/0/locations/0)
#  119|   	if (fd >= 0) {
#  120|   		n = write(fd, devnm, strlen(devnm));
#  121|-> 		close(fd);
#  122|   	}
#  123|   	if (fd < 0 || n != (int)strlen(devnm)) {

Error: GCC_ANALYZER_WARNING (CWE-775): [#def80]
mdadm-4.3/mdopen.c:470:13: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(dev, 0)’
mdadm-4.3/mdopen.c:461:20: acquire_resource: opened here
mdadm-4.3/mdopen.c:463:12: branch_false: following ‘false’ branch...
mdadm-4.3/mdopen.c:470:13: branch_false: ...to here
mdadm-4.3/mdopen.c:470:13: throw: if ‘md_array_valid’ throws an exception...
mdadm-4.3/mdopen.c:470:13: danger: ‘open(dev, 0)’ leaks here; was opened at [(1)](sarif:/runs/0/results/4/codeFlows/0/threadFlows/0/locations/0)
#  468|   	}
#  469|   
#  470|-> 	if (md_array_valid(mdfd) == 0) {
#  471|   		close(mdfd);
#  472|   		if (report_errors)

Error: GCC_ANALYZER_WARNING (CWE-775): [#def81]
mdadm-4.3/mdstat.c:150:17: warning[-Wanalyzer-file-leak]: leak of FILE ‘f’
mdadm-4.3/mdstat.c:411:20: enter_function: entry to ‘mdstat_by_subdev’
mdadm-4.3/mdstat.c:413:37: call_function: calling ‘mdstat_read’ from ‘mdstat_by_subdev’
#  148|   		return NULL;
#  149|   	else
#  150|-> 		fcntl(fileno(f), F_SETFD, FD_CLOEXEC);
#  151|   
#  152|   	all = NULL;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def82]
mdadm-4.3/mdstat.c:150:17: warning[-Wanalyzer-malloc-leak]: leak of ‘f’
mdadm-4.3/mdstat.c:411:20: enter_function: entry to ‘mdstat_by_subdev’
mdadm-4.3/mdstat.c:413:37: call_function: calling ‘mdstat_read’ from ‘mdstat_by_subdev’
#  148|   		return NULL;
#  149|   	else
#  150|-> 		fcntl(fileno(f), F_SETFD, FD_CLOEXEC);
#  151|   
#  152|   	all = NULL;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def83]
mdadm-4.3/mdstat.c:154:24: warning[-Wanalyzer-file-leak]: leak of FILE ‘f’
mdadm-4.3/mdstat.c:411:20: enter_function: entry to ‘mdstat_by_subdev’
mdadm-4.3/mdstat.c:413:37: call_function: calling ‘mdstat_read’ from ‘mdstat_by_subdev’
#  152|   	all = NULL;
#  153|   	end = &all;
#  154|-> 	for (; (line = conf_line(f)) ; free_line(line)) {
#  155|   		struct mdstat_ent *ent;
#  156|   		char *w;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def84]
mdadm-4.3/mdstat.c:154:24: warning[-Wanalyzer-malloc-leak]: leak of ‘f’
mdadm-4.3/mdstat.c:411:20: enter_function: entry to ‘mdstat_by_subdev’
mdadm-4.3/mdstat.c:413:37: call_function: calling ‘mdstat_read’ from ‘mdstat_by_subdev’
#  152|   	all = NULL;
#  153|   	end = &all;
#  154|-> 	for (; (line = conf_line(f)) ; free_line(line)) {
#  155|   		struct mdstat_ent *ent;
#  156|   		char *w;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def85]
mdadm-4.3/platform-intel.c:86:19: warning[-Wanalyzer-malloc-leak]: leak of ‘opendir(&path)’
mdadm-4.3/platform-intel.c:278:17: enter_function: entry to ‘find_intel_devices’
mdadm-4.3/platform-intel.c:288:16: call_function: calling ‘find_driver_devices’ from ‘find_intel_devices’
#   84|   		return NULL;
#   85|   	}
#   86|-> 	for (de = readdir(driver_dir); de; de = readdir(driver_dir)) {
#   87|   		int n;
#   88|   		int skip = 0;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def86]
mdadm-4.3/platform-intel.c:226:13: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(__builtin_alloca_with_align(strnlen(dev_path, 4096) + strnlen(entry, 4096) + 2, 8), 0)’
mdadm-4.3/platform-intel.c:278:17: enter_function: entry to ‘find_intel_devices’
mdadm-4.3/platform-intel.c:288:16: call_function: calling ‘find_driver_devices’ from ‘find_intel_devices’
#  224|   	if (fd < 0)
#  225|   		return -1;
#  226|-> 	n = sysfs_fd_get_ll(fd, val);
#  227|   	close(fd);
#  228|   	return n;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def87]
mdadm-4.3/platform-intel.c:250:9: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(__builtin_alloca_with_align(strlen(dev_path) + 8, 8), 0)’
mdadm-4.3/platform-intel.c:278:17: enter_function: entry to ‘find_intel_devices’
mdadm-4.3/platform-intel.c:288:16: call_function: calling ‘find_driver_devices’ from ‘find_intel_devices’
#  248|   		id = strtoul(vendor, NULL, 16);
#  249|   	}
#  250|-> 	close(fd);
#  251|   
#  252|   	return id;

Error: CPPCHECK_WARNING (CWE-758): [#def88]
mdadm-4.3/platform-intel.c:460: error[shiftTooManyBitsSigned]: Shifting signed 32-bit value by 31 bits is undefined behaviour
#  458|   		.vphba = IMSM_OROM_VOLUMES_PER_HBA
#  459|   	};
#  460|-> 	orom.attr = orom.rlc | IMSM_OROM_ATTR_ChecksumVerify;
#  461|   
#  462|   	if (check_env("IMSM_TEST_OROM_NORAID5")) {

Error: GCC_ANALYZER_WARNING (CWE-775): [#def89]
mdadm-4.3/platform-intel.c:551:17: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(&path, 0)’
mdadm-4.3/platform-intel.c:614:25: enter_function: entry to ‘find_imsm_efi’
mdadm-4.3/platform-intel.c:632:22: call_function: calling ‘read_efi_variable’ from ‘find_imsm_efi’
#  549|   	n = read(fd, buf, sizeof(__u32));
#  550|   	if (n < 0) {
#  551|-> 		close(fd);
#  552|   		return 1;
#  553|   	}

Error: GCC_ANALYZER_WARNING (CWE-775): [#def90]
mdadm-4.3/platform-intel.c:556:13: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(&path, 0)’
mdadm-4.3/platform-intel.c:614:25: enter_function: entry to ‘find_imsm_efi’
mdadm-4.3/platform-intel.c:632:22: call_function: calling ‘read_efi_variable’ from ‘find_imsm_efi’
#  554|   
#  555|   	/* read the variable data */
#  556|-> 	n = read(fd, buffer, buf_size);
#  557|   	close(fd);
#  558|   	if (n < buf_size)

Error: GCC_ANALYZER_WARNING (CWE-775): [#def91]
mdadm-4.3/platform-intel.c:586:9: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(&path, 0)’
mdadm-4.3/platform-intel.c:614:25: enter_function: entry to ‘find_imsm_efi’
mdadm-4.3/platform-intel.c:632:22: call_function: calling ‘read_efi_variable’ from ‘find_imsm_efi’
#  584|   
#  585|   	n = read(dfd, &buf, sizeof(buf));
#  586|-> 	close(dfd);
#  587|   	if (n < 0)
#  588|   		return 1;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def92]
mdadm-4.3/platform-intel.c:605:13: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(&path, 0)’
mdadm-4.3/platform-intel.c:614:25: enter_function: entry to ‘find_imsm_efi’
mdadm-4.3/platform-intel.c:632:22: call_function: calling ‘read_efi_variable’ from ‘find_imsm_efi’
#  603|   		return 1;
#  604|   
#  605|-> 	n = read(dfd, buffer, buf_size);
#  606|   	close(dfd);
#  607|   	if (n != var_data_len || n < buf_size) {

Error: GCC_ANALYZER_WARNING (CWE-401): [#def93]
mdadm-4.3/platform-intel.c:995:20: warning[-Wanalyzer-malloc-leak]: leak of ‘opendir("/sys/bus/pci/drivers/vmd")’
mdadm-4.3/platform-intel.c:991:15: acquire_memory: allocated here
mdadm-4.3/platform-intel.c:992:12: branch_false: following ‘false’ branch...
mdadm-4.3/platform-intel.c:995:20: branch_false: ...to here
mdadm-4.3/platform-intel.c:995:20: throw: if ‘readdir’ throws an exception...
mdadm-4.3/platform-intel.c:995:20: danger: ‘opendir("/sys/bus/pci/drivers/vmd")’ leaks here; was allocated at [(1)](sarif:/runs/0/results/7/codeFlows/0/threadFlows/0/locations/0)
#  993|   		return NULL;
#  994|   
#  995|-> 	for (ent = readdir(dir); ent; ent = readdir(dir)) {
#  996|   		sprintf(path, "/sys/bus/pci/drivers/vmd/%s/domain/device",
#  997|   			ent->d_name);

Error: COMPILER_WARNING: [#def94]
mdadm-4.3/platform-intel.c:20: included_from: Included from here.
mdadm-4.3/platform-intel.c: scope_hint: In function ‘imsm_platform_test’
mdadm-4.3/platform-intel.h:28:37: warning[-Wunterminated-string-initialization]: initializer-string for array of ‘unsigned char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (5 chars into 4 available)
#   28 |         #define IMSM_OROM_SIGNATURE "$VER"
#      |                                     ^~~~~~
mdadm-4.3/platform-intel.c:447:30: note: in expansion of macro ‘IMSM_OROM_SIGNATURE’
#  447 |                 .signature = IMSM_OROM_SIGNATURE,
#      |                              ^~~~~~~~~~~~~~~~~~~
#   26|   struct imsm_orom {
#   27|   	__u8 signature[4];
#   28|-> 	#define IMSM_OROM_SIGNATURE "$VER"
#   29|   	#define IMSM_NVME_OROM_COMPAT_SIGNATURE "$NVM"
#   30|   	#define IMSM_VMD_OROM_COMPAT_SIGNATURE "$VMD"

Error: COMPILER_WARNING: [#def95]
mdadm-4.3/platform-intel.c: scope_hint: In function ‘find_imsm_nvme’
mdadm-4.3/platform-intel.h:29:49: warning[-Wunterminated-string-initialization]: initializer-string for array of ‘unsigned char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (5 chars into 4 available)
#   29 |         #define IMSM_NVME_OROM_COMPAT_SIGNATURE "$NVM"
#      |                                                 ^~~~~~
mdadm-4.3/platform-intel.c:683:38: note: in expansion of macro ‘IMSM_NVME_OROM_COMPAT_SIGNATURE’
#  683 |                         .signature = IMSM_NVME_OROM_COMPAT_SIGNATURE,
#      |                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#   27|   	__u8 signature[4];
#   28|   	#define IMSM_OROM_SIGNATURE "$VER"
#   29|-> 	#define IMSM_NVME_OROM_COMPAT_SIGNATURE "$NVM"
#   30|   	#define IMSM_VMD_OROM_COMPAT_SIGNATURE "$VMD"
#   31|   	__u8 table_ver_major; /* Currently 2 (can change with future revs) */

Error: COMPILER_WARNING: [#def96]
mdadm-4.3/platform-intel.c: scope_hint: In function ‘add_vmd_orom’
mdadm-4.3/platform-intel.h:30:48: warning[-Wunterminated-string-initialization]: initializer-string for array of ‘unsigned char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (5 chars into 4 available)
#   30 |         #define IMSM_VMD_OROM_COMPAT_SIGNATURE "$VMD"
#      |                                                ^~~~~~
mdadm-4.3/platform-intel.c:751:30: note: in expansion of macro ‘IMSM_VMD_OROM_COMPAT_SIGNATURE’
#  751 |                 .signature = IMSM_VMD_OROM_COMPAT_SIGNATURE,
#      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#   28|   	#define IMSM_OROM_SIGNATURE "$VER"
#   29|   	#define IMSM_NVME_OROM_COMPAT_SIGNATURE "$NVM"
#   30|-> 	#define IMSM_VMD_OROM_COMPAT_SIGNATURE "$VMD"
#   31|   	__u8 table_ver_major; /* Currently 2 (can change with future revs) */
#   32|   	__u8 table_ver_minor; /* Currently 2 (can change with future revs) */

Error: GCC_ANALYZER_WARNING (CWE-401): [#def97]
mdadm-4.3/policy.c:207:31: warning[-Wanalyzer-malloc-leak]: leak of ‘opendir(&symlink)’
mdadm-4.3/policy.c:773:5: enter_function: entry to ‘policy_check_path’
mdadm-4.3/policy.c:777:27: call_function: calling ‘disk_paths’ from ‘policy_check_path’
#  205|   	if (by_path) {
#  206|   		prefix_len = strlen(symlink);
#  207|-> 		while ((ent = readdir(by_path)) != NULL) {
#  208|   			if (ent->d_type != DT_LNK)
#  209|   				continue;

Error: GCC_ANALYZER_WARNING (CWE-688): [#def98]
mdadm-4.3/policy.c:340:37: warning[-Wanalyzer-null-argument]: use of NULL ‘part’ where non-null expected
mdadm-4.3/policy.c:706:20: enter_function: entry to ‘domain_from_array’
mdadm-4.3/policy.c:710:12: branch_false: following ‘false’ branch (when ‘mdi’ is non-NULL)...
mdadm-4.3/policy.c:712:14: branch_false: ...to here
mdadm-4.3/policy.c:712:32: branch_true: following ‘true’ branch (when ‘mdi’ is non-NULL)...
mdadm-4.3/policy.c:713:46: branch_true: ...to here
mdadm-4.3/policy.c:713:17: call_function: calling ‘domainlist_add_dev’ from ‘domain_from_array’
#  338|   			for (dom = dl_next(r->dups); dom != r->dups;
#  339|   			     dom = dl_next(dom))
#  340|-> 				if (strcmp(dom+len+1, part)== 0)
#  341|   					break;
#  342|   			if (dom == r->dups) {

Error: GCC_ANALYZER_WARNING (CWE-688): [#def99]
mdadm-4.3/policy.c:344:61: warning[-Wanalyzer-null-argument]: use of NULL ‘part’ where non-null expected
mdadm-4.3/policy.c:706:20: enter_function: entry to ‘domain_from_array’
mdadm-4.3/policy.c:710:12: branch_false: following ‘false’ branch (when ‘mdi’ is non-NULL)...
mdadm-4.3/policy.c:712:14: branch_false: ...to here
mdadm-4.3/policy.c:712:32: branch_true: following ‘true’ branch (when ‘mdi’ is non-NULL)...
mdadm-4.3/policy.c:713:46: branch_true: ...to here
mdadm-4.3/policy.c:713:17: call_function: calling ‘domainlist_add_dev’ from ‘domain_from_array’
#  342|   			if (dom == r->dups) {
#  343|   				char *newdom = dl_strndup(
#  344|-> 					r->value, len + 1 + strlen(part));
#  345|   				strcat(strcat(newdom, "-"), part);
#  346|   				dl_add(r->dups, newdom);

Error: GCC_ANALYZER_WARNING (CWE-775): [#def100]
mdadm-4.3/policy.c:911:13: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘fd’
mdadm-4.3/policy.c:899:12: branch_true: following ‘true’ branch (when ‘rule_name’ is non-NULL)...
mdadm-4.3/policy.c:900:17: branch_true: ...to here
mdadm-4.3/policy.c:903:22: acquire_resource: opened here
mdadm-4.3/policy.c:905:20: branch_false: following ‘false’ branch...
mdadm-4.3/policy.c:911:13: branch_false: ...to here
mdadm-4.3/policy.c:911:13: throw: if ‘write’ throws an exception...
mdadm-4.3/policy.c:911:13: danger: ‘fd’ leaks here; was opened at [(4)](sarif:/runs/0/results/3/codeFlows/0/threadFlows/0/locations/3)
#  909|   
#  910|   	/* write static invocation */
#  911|-> 	if (write(fd, udev_template_start, sizeof(udev_template_start) - 1) !=
#  912|   	    (int)sizeof(udev_template_start) - 1)
#  913|   		goto abort;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def101]
mdadm-4.3/policy.c:919:9: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘fd’
mdadm-4.3/policy.c:899:12: branch_true: following ‘true’ branch (when ‘rule_name’ is non-NULL)...
mdadm-4.3/policy.c:900:17: branch_true: ...to here
mdadm-4.3/policy.c:903:22: acquire_resource: opened here
mdadm-4.3/policy.c:905:20: branch_false: following ‘false’ branch...
mdadm-4.3/policy.c:911:13: branch_false: ...to here
mdadm-4.3/policy.c:911:12: branch_false: following ‘false’ branch...
mdadm-4.3/policy.c:916:13: branch_false: ...to here
mdadm-4.3/policy.c:919:9: throw: if ‘fsync’ throws an exception...
mdadm-4.3/policy.c:919:9: danger: ‘fd’ leaks here; was opened at [(4)](sarif:/runs/0/results/4/codeFlows/0/threadFlows/0/locations/3)
#  917|   		goto abort;
#  918|   
#  919|-> 	fsync(fd);
#  920|   	if (rule_name) {
#  921|   		close(fd);

Error: GCC_ANALYZER_WARNING (CWE-775): [#def102]
mdadm-4.3/policy.c:927:17: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘fd’
mdadm-4.3/policy.c:899:12: branch_true: following ‘true’ branch (when ‘rule_name’ is non-NULL)...
mdadm-4.3/policy.c:900:17: branch_true: ...to here
mdadm-4.3/policy.c:903:22: acquire_resource: opened here
mdadm-4.3/policy.c:905:20: branch_false: following ‘false’ branch...
mdadm-4.3/policy.c:911:13: branch_false: ...to here
mdadm-4.3/policy.c:911:12: branch_true: following ‘true’ branch...
mdadm-4.3/policy.c:913:17: branch_true: ...to here
mdadm-4.3/policy.c:926:12: branch_true: following ‘true’ branch (when ‘rule_name’ is non-NULL)...
mdadm-4.3/policy.c:927:17: branch_true: ...to here
mdadm-4.3/policy.c:927:17: throw: if ‘close’ throws an exception...
mdadm-4.3/policy.c:927:17: danger: ‘fd’ leaks here; was opened at [(4)](sarif:/runs/0/results/5/codeFlows/0/threadFlows/0/locations/3)
#  925|   abort:
#  926|   	if (rule_name) {
#  927|-> 		close(fd);
#  928|   		unlink(udev_rule_file);
#  929|   	}

Error: GCC_ANALYZER_WARNING (CWE-465): [#def103]
mdadm-4.3/probe_roms.c:316:20: warning[-Wanalyzer-deref-before-check]: check of ‘res’ for NULL after already dereferencing it
mdadm-4.3/probe_roms.c:243:6: enter_function: entry to ‘probe_roms’
mdadm-4.3/probe_roms.c:251:12: branch_false: following ‘false’ branch...
mdadm-4.3/probe_roms.c:255:9: branch_false: ...to here
mdadm-4.3/probe_roms.c:292:16: branch_true: following ‘true’ branch (when ‘start < upper’)...
mdadm-4.3/probe_roms.c:293:23: call_function: inlined call to ‘isa_bus_to_virt’ from ‘probe_roms’
mdadm-4.3/probe_roms.c:294:22: call_function: inlined call to ‘romsignature’ from ‘probe_roms’
mdadm-4.3/probe_roms.c:313:59: call_function: calling ‘romchecksum’ from ‘probe_roms’
mdadm-4.3/probe_roms.c:313:59: return_function: returning to ‘probe_roms’ from ‘romchecksum’
mdadm-4.3/probe_roms.c:316:20: danger: pointer ‘res’ is checked for NULL here but it was already dereferenced at [(4)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/3)
#  314|   			continue;
#  315|   
#  316|-> 		if (res == NULL) {
#  317|   			res = calloc(1, sizeof(struct resource));
#  318|   			if (res == NULL)

Error: GCC_ANALYZER_WARNING (CWE-775): [#def104]
mdadm-4.3/raid6check.c:566:16: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(argv[1], 0)’
mdadm-4.3/raid6check.c:551:12: branch_false: following ‘false’ branch (when ‘argc > 3’)...
mdadm-4.3/raid6check.c:558:16: branch_false: ...to here
mdadm-4.3/raid6check.c:558:16: acquire_resource: opened here
mdadm-4.3/raid6check.c:559:11: branch_false: following ‘false’ branch...
mdadm-4.3/raid6check.c:566:16: branch_false: ...to here
mdadm-4.3/raid6check.c:566:16: throw: if ‘sysfs_read’ throws an exception...
mdadm-4.3/raid6check.c:566:16: danger: ‘open(argv[1], 0)’ leaks here; was opened at [(3)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/2)
#  564|   	}
#  565|   
#  566|-> 	info = sysfs_read(mdfd, NULL,
#  567|   			  GET_LEVEL|
#  568|   			  GET_LAYOUT|

Error: GCC_ANALYZER_WARNING (CWE-476): [#def105]
mdadm-4.3/super-ddf.c:861:13: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘0’
mdadm-4.3/super-ddf.c:3556:12: enter_function: entry to ‘load_container_ddf’
mdadm-4.3/super-ddf.c:3559:16: call_function: calling ‘load_super_ddf_all’ from ‘load_container_ddf’
#  859|   		return NULL;
#  860|   
#  861|-> 	if (super->active->type == 1)
#  862|   		offset += be64_to_cpu(super->active->primary_lba);
#  863|   	else

Error: CPPCHECK_WARNING (CWE-457): [#def106]
mdadm-4.3/super-ddf.c:1604: warning[uninitvar]: Uninitialized variable: end
# 1602|   	if (sub != NULL)
# 1603|   		vcnum = strtoul(sub + 1, &end, 10);
# 1604|-> 	if (sub == NULL || *sub == '\0' || *end != '\0' ||
# 1605|   	    vcnum >= be16_to_cpu(ddf->active->max_vd_entries)) {
# 1606|   		sysfs_free(sra);

Error: CPPCHECK_WARNING (CWE-457): [#def107]
mdadm-4.3/super-ddf.c:1605: warning[uninitvar]: Uninitialized variable: vcnum
# 1603|   		vcnum = strtoul(sub + 1, &end, 10);
# 1604|   	if (sub == NULL || *sub == '\0' || *end != '\0' ||
# 1605|-> 	    vcnum >= be16_to_cpu(ddf->active->max_vd_entries)) {
# 1606|   		sysfs_free(sra);
# 1607|   		return DDF_NOTFOUND;

Error: CPPCHECK_WARNING (CWE-457): [#def108]
mdadm-4.3/super-intel.c:8348: error[legacyUninitvar]: Uninitialized variable: insync
# 8346|   		int i;
# 8347|   		/* gcc -Os complains that this is unused */
# 8348|-> 		int insync = insync;
# 8349|   
# 8350|   		for (i = 0; i < map->num_members; i++) {

Error: GCC_ANALYZER_WARNING (CWE-775): [#def109]
mdadm-4.3/super1.c:1320:25: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(devname, 0)’
mdadm-4.3/super1.c:1196:12: branch_false: following ‘false’ branch...
mdadm-4.3/super1.c:1211:9: branch_false: ...to here
mdadm-4.3/super1.c:1297:20: branch_false: following ‘false’ branch (when ‘max <= 1920’)...
mdadm-4.3/super1.c:1297:20: branch_false: ...to here
mdadm-4.3/super1.c:1304:20: branch_false: following ‘false’ branch...
mdadm-4.3/super1.c:1306:34: branch_false: ...to here
mdadm-4.3/super1.c:1310:20: branch_false: following ‘false’ branch (when ‘i <= max’)...
mdadm-4.3/super1.c:1313:29: branch_false: ...to here
mdadm-4.3/super1.c:1317:22: acquire_resource: opened here
mdadm-4.3/super1.c:1318:20: branch_true: following ‘true’ branch...
mdadm-4.3/super1.c:1320:25: branch_true: ...to here
mdadm-4.3/super1.c:1320:25: throw: if ‘get_dev_size’ throws an exception...
mdadm-4.3/super1.c:1320:25: danger: ‘open(devname, 0)’ leaks here; was opened at [(11)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/10)
# 1318|   		if (fd >= 0) {
# 1319|   			unsigned long long ds;
# 1320|-> 			get_dev_size(fd, devname, &ds);
# 1321|   			close(fd);
# 1322|   			ds >>= 9;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def110]
mdadm-4.3/sysfs.c:51:13: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(path, 0)’
mdadm-4.3/sysfs.c:47:18: acquire_resource: opened here
mdadm-4.3/sysfs.c:49:12: branch_false: following ‘false’ branch...
mdadm-4.3/sysfs.c:51:13: branch_false: ...to here
mdadm-4.3/sysfs.c:51:13: danger: ‘open(path, 0)’ leaks here; was opened at [(1)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/0)
#   49|   	if (fd < 0)
#   50|   		return -1;
#   51|-> 	n = read(fd, buf, len);
#   52|   	close(fd);
#   53|   	if (n <0 || n >= len)

Error: GCC_ANALYZER_WARNING (CWE-401): [#def111]
mdadm-4.3/sysfs.c:286:22: warning[-Wanalyzer-malloc-leak]: leak of ‘opendir(&fname)’
mdadm-4.3/sysfs.c:138:12: branch_false: following ‘false’ branch...
mdadm-4.3/sysfs.c:143:45: branch_false: ...to here
mdadm-4.3/sysfs.c:198:12: branch_false: following ‘false’ branch...
mdadm-4.3/sysfs.c:206:13: branch_false: ...to here
mdadm-4.3/sysfs.c:206:12: branch_false: following ‘false’ branch...
mdadm-4.3/sysfs.c:212:13: branch_false: ...to here
mdadm-4.3/sysfs.c:212:12: branch_false: following ‘false’ branch...
mdadm-4.3/sysfs.c:241:13: branch_false: ...to here
mdadm-4.3/sysfs.c:241:12: branch_false: following ‘false’ branch...
mdadm-4.3/sysfs.c:255:13: branch_false: ...to here
mdadm-4.3/sysfs.c:255:12: branch_false: following ‘false’ branch...
mdadm-4.3/sysfs.c:262:13: branch_false: ...to here
mdadm-4.3/sysfs.c:262:12: branch_false: following ‘false’ branch...
mdadm-4.3/sysfs.c:271:15: branch_false: ...to here
mdadm-4.3/sysfs.c:271:12: branch_false: following ‘false’ branch...
mdadm-4.3/sysfs.c:275:9: branch_false: ...to here
mdadm-4.3/sysfs.c:276:15: acquire_memory: allocated here
mdadm-4.3/sysfs.c:277:12: branch_false: following ‘false’ branch...
mdadm-4.3/sysfs.c:279:9: branch_false: ...to here
mdadm-4.3/sysfs.c:286:22: throw: if ‘readdir’ throws an exception...
mdadm-4.3/sysfs.c:286:22: danger: ‘opendir(&fname)’ leaks here; was allocated at [(17)](sarif:/runs/0/results/1/codeFlows/0/threadFlows/0/locations/16)
#  284|   	devp = &sra->devs;
#  285|   	sra->devs = NULL;
#  286|-> 	while ((de = readdir(dir)) != NULL) {
#  287|   		char *ep;
#  288|   		if (de->d_ino == 0 ||

Error: GCC_ANALYZER_WARNING (CWE-775): [#def112]
mdadm-4.3/sysfs.c:453:9: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(&fname, 0)’
mdadm-4.3/sysfs.c:445:12: branch_false: following ‘false’ branch...
mdadm-4.3/sysfs.c:447:9: branch_false: ...to here
mdadm-4.3/sysfs.c:449:14: acquire_resource: opened here
mdadm-4.3/sysfs.c:450:12: branch_false: following ‘false’ branch...
mdadm-4.3/sysfs.c:452:13: branch_false: ...to here
mdadm-4.3/sysfs.c:453:9: danger: ‘open(&fname, 0)’ leaks here; was opened at [(3)](sarif:/runs/0/results/2/codeFlows/0/threadFlows/0/locations/2)
#  451|   		return 0;
#  452|   	n = read(fd, fname, sizeof(fname));
#  453|-> 	close(fd);
#  454|   	if (n < 0 || n == sizeof(fname))
#  455|   		return 0;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def113]
mdadm-4.3/sysfs.c:472:13: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(&fname, 1)’
mdadm-4.3/sysfs.c:469:14: acquire_resource: opened here
mdadm-4.3/sysfs.c:470:12: branch_false: following ‘false’ branch...
mdadm-4.3/sysfs.c:472:13: branch_false: ...to here
mdadm-4.3/sysfs.c:472:13: throw: if ‘write’ throws an exception...
mdadm-4.3/sysfs.c:472:13: danger: ‘open(&fname, 1)’ leaks here; was opened at [(1)](sarif:/runs/0/results/3/codeFlows/0/threadFlows/0/locations/0)
#  470|   	if (fd < 0)
#  471|   		return -1;
#  472|-> 	n = write(fd, val, strlen(val));
#  473|   	close(fd);
#  474|   	if (n != strlen(val)) {

Error: GCC_ANALYZER_WARNING (CWE-775): [#def114]
mdadm-4.3/sysfs.c:473:9: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(&fname, 1)’
mdadm-4.3/sysfs.c:469:14: acquire_resource: opened here
mdadm-4.3/sysfs.c:470:12: branch_false: following ‘false’ branch...
mdadm-4.3/sysfs.c:472:13: branch_false: ...to here
mdadm-4.3/sysfs.c:473:9: danger: ‘open(&fname, 1)’ leaks here; was opened at [(1)](sarif:/runs/0/results/4/codeFlows/0/threadFlows/0/locations/0)
#  471|   		return -1;
#  472|   	n = write(fd, val, strlen(val));
#  473|-> 	close(fd);
#  474|   	if (n != strlen(val)) {
#  475|   		dprintf("failed to write '%s' to '%s' (%s)\n",

Error: GCC_ANALYZER_WARNING (CWE-775): [#def115]
mdadm-4.3/sysfs.c:509:13: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(&fname, 1)’
mdadm-4.3/sysfs.c:506:14: acquire_resource: opened here
mdadm-4.3/sysfs.c:507:12: branch_false: following ‘false’ branch...
mdadm-4.3/sysfs.c:509:13: branch_false: ...to here
mdadm-4.3/sysfs.c:509:13: throw: if ‘write’ throws an exception...
mdadm-4.3/sysfs.c:509:13: danger: ‘open(&fname, 1)’ leaks here; was opened at [(1)](sarif:/runs/0/results/5/codeFlows/0/threadFlows/0/locations/0)
#  507|   	if (fd < 0)
#  508|   		return -1;
#  509|-> 	n = write(fd, event, strlen(event));
#  510|   	close(fd);
#  511|   	if (n != (int)strlen(event)) {

Error: GCC_ANALYZER_WARNING (CWE-775): [#def116]
mdadm-4.3/sysfs.c:510:9: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(&fname, 1)’
mdadm-4.3/sysfs.c:506:14: acquire_resource: opened here
mdadm-4.3/sysfs.c:507:12: branch_false: following ‘false’ branch...
mdadm-4.3/sysfs.c:509:13: branch_false: ...to here
mdadm-4.3/sysfs.c:510:9: danger: ‘open(&fname, 1)’ leaks here; was opened at [(1)](sarif:/runs/0/results/6/codeFlows/0/threadFlows/0/locations/0)
#  508|   		return -1;
#  509|   	n = write(fd, event, strlen(event));
#  510|-> 	close(fd);
#  511|   	if (n != (int)strlen(event)) {
#  512|   		dprintf("failed to write '%s' to '%s' (%s)\n",

Error: GCC_ANALYZER_WARNING (CWE-401): [#def117]
mdadm-4.3/sysfs.c:825:19: warning[-Wanalyzer-malloc-leak]: leak of ‘opendir(&path)’
mdadm-4.3/sysfs.c:815:12: branch_false: following ‘false’ branch...
mdadm-4.3/sysfs.c:818:9: branch_false: ...to here
mdadm-4.3/sysfs.c:821:15: acquire_memory: allocated here
mdadm-4.3/sysfs.c:822:12: branch_false: following ‘false’ branch...
mdadm-4.3/sysfs.c:825:19: branch_false: ...to here
mdadm-4.3/sysfs.c:825:19: throw: if ‘readdir’ throws an exception...
mdadm-4.3/sysfs.c:825:19: danger: ‘opendir(&path)’ leaks here; was allocated at [(3)](sarif:/runs/0/results/7/codeFlows/0/threadFlows/0/locations/2)
#  823|   		return 1;
#  824|   
#  825|-> 	for (de = readdir(dir); de; de = readdir(dir)) {
#  826|   		int count;
#  827|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def118]
mdadm-4.3/sysfs.c:867:22: warning[-Wanalyzer-malloc-leak]: leak of ‘opendir(&dirname)’
mdadm-4.3/sysfs.c:863:15: acquire_memory: allocated here
mdadm-4.3/sysfs.c:864:12: branch_false: following ‘false’ branch...
mdadm-4.3/sysfs.c:866:13: branch_false: ...to here
mdadm-4.3/sysfs.c:867:22: throw: if ‘readdir’ throws an exception...
mdadm-4.3/sysfs.c:867:22: danger: ‘opendir(&dirname)’ leaks here; was allocated at [(1)](sarif:/runs/0/results/8/codeFlows/0/threadFlows/0/locations/0)
#  865|   		return -1;
#  866|   	l = strlen(dirname);
#  867|-> 	while ((de = readdir(dir)) != NULL) {
#  868|   		char buf[100];
#  869|   		char *sl;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def119]
mdadm-4.3/util.c:955:17: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(&path, 0)’
mdadm-4.3/util.c:951:14: acquire_resource: opened here
mdadm-4.3/util.c:952:12: branch_true: following ‘true’ branch...
mdadm-4.3/util.c:954:25: branch_true: ...to here
mdadm-4.3/util.c:955:17: danger: ‘open(&path, 0)’ leaks here; was opened at [(1)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/0)
#  953|   		char buf[20];
#  954|   		int n = read(fd, buf, sizeof(buf));
#  955|-> 		close(fd);
#  956|   		if (n > 0)
#  957|   			buf[n] = 0;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def120]
mdadm-4.3/util.c:1056:9: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘dev_open(&buf, 0)’
mdadm-4.3/util.c:1582:5: enter_function: entry to ‘open_container’
mdadm-4.3/util.c:1596:12: branch_false: following ‘false’ branch...
mdadm-4.3/util.c:1599:46: branch_false: ...to here
mdadm-4.3/util.c:1603:12: branch_false: following ‘false’ branch...
mdadm-4.3/util.c:1603:12: branch_false: ...to here
mdadm-4.3/util.c:1605:16: branch_true: following ‘true’ branch...
mdadm-4.3/util.c:1606:21: branch_true: ...to here
mdadm-4.3/util.c:1636:23: call_function: calling ‘dev_open’ from ‘open_container’
mdadm-4.3/util.c:1636:23: return_function: returning to ‘open_container’ from ‘dev_open’
mdadm-4.3/util.c:1638:25: throw: if ‘closedir’ throws an exception...
mdadm-4.3/util.c:1056:9: danger: ‘dev_open(&buf, 0)’ leaks here; was opened at [(12)](sarif:/runs/0/results/1/codeFlows/0/threadFlows/0/locations/11)
# 1054|   {
# 1055|   	char *e;
# 1056|-> 	*major = strtoul(dev, &e, 0);
# 1057|   	return (e > dev && *e == ':' && e[1] &&
# 1058|   		(*minor = strtoul(e+1, &e, 0)) >= 0 &&

Error: GCC_ANALYZER_WARNING (CWE-401): [#def121]
mdadm-4.3/util.c:1605:22: warning[-Wanalyzer-malloc-leak]: leak of ‘opendir(&path)’
mdadm-4.3/util.c:1596:12: branch_false: following ‘false’ branch...
mdadm-4.3/util.c:1599:46: branch_false: ...to here
mdadm-4.3/util.c:1602:15: acquire_memory: allocated here
mdadm-4.3/util.c:1603:12: branch_false: following ‘false’ branch...
mdadm-4.3/util.c:1603:12: branch_false: ...to here
mdadm-4.3/util.c:1605:22: throw: if ‘readdir’ throws an exception...
mdadm-4.3/util.c:1605:22: danger: ‘opendir(&path)’ leaks here; was allocated at [(3)](sarif:/runs/0/results/2/codeFlows/0/threadFlows/0/locations/2)
# 1603|   	if (!dir)
# 1604|   		return -1;
# 1605|-> 	while ((de = readdir(dir))) {
# 1606|   		if (de->d_ino == 0)
# 1607|   			continue;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def122]
mdadm-4.3/util.c:1616:17: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(&path, 0)’
mdadm-4.3/util.c:1596:12: branch_false: following ‘false’ branch...
mdadm-4.3/util.c:1599:46: branch_false: ...to here
mdadm-4.3/util.c:1603:12: branch_false: following ‘false’ branch...
mdadm-4.3/util.c:1603:12: branch_false: ...to here
mdadm-4.3/util.c:1605:16: branch_true: following ‘true’ branch...
mdadm-4.3/util.c:1606:21: branch_true: ...to here
mdadm-4.3/util.c:1608:20: branch_false: following ‘false’ branch...
mdadm-4.3/util.c:1611:55: branch_false: ...to here
mdadm-4.3/util.c:1612:23: acquire_resource: opened here
mdadm-4.3/util.c:1613:20: branch_false: following ‘false’ branch...
mdadm-4.3/util.c:1615:21: branch_false: ...to here
mdadm-4.3/util.c:1616:17: danger: ‘open(&path, 0)’ leaks here; was opened at [(9)](sarif:/runs/0/results/3/codeFlows/0/threadFlows/0/locations/8)
# 1614|   			continue;
# 1615|   		n = read(dfd, buf, sizeof(buf));
# 1616|-> 		close(dfd);
# 1617|   		if (n <= 0 || (unsigned)n >= sizeof(buf))
# 1618|   			continue;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def123]
mdadm-4.3/util.c:1629:17: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(&path, 0)’
mdadm-4.3/util.c:1596:12: branch_false: following ‘false’ branch...
mdadm-4.3/util.c:1599:46: branch_false: ...to here
mdadm-4.3/util.c:1603:12: branch_false: following ‘false’ branch...
mdadm-4.3/util.c:1603:12: branch_false: ...to here
mdadm-4.3/util.c:1605:16: branch_true: following ‘true’ branch...
mdadm-4.3/util.c:1606:21: branch_true: ...to here
mdadm-4.3/util.c:1608:20: branch_false: following ‘false’ branch...
mdadm-4.3/util.c:1611:55: branch_false: ...to here
mdadm-4.3/util.c:1613:20: branch_false: following ‘false’ branch...
mdadm-4.3/util.c:1615:21: branch_false: ...to here
mdadm-4.3/util.c:1617:20: branch_false: following ‘false’ branch...
mdadm-4.3/util.c:1619:17: branch_false: ...to here
mdadm-4.3/util.c:1620:20: branch_false: following ‘false’ branch...
mdadm-4.3/util.c:1620:21: branch_false: following ‘false’ branch...
mdadm-4.3/util.c:1624:17: branch_false: ...to here
mdadm-4.3/util.c:1625:23: acquire_resource: opened here
mdadm-4.3/util.c:1626:20: branch_false: following ‘false’ branch...
mdadm-4.3/util.c:1628:21: branch_false: ...to here
mdadm-4.3/util.c:1629:17: danger: ‘open(&path, 0)’ leaks here; was opened at [(17)](sarif:/runs/0/results/4/codeFlows/0/threadFlows/0/locations/16)
# 1627|   			continue;
# 1628|   		n = read(dfd, buf, sizeof(buf));
# 1629|-> 		close(dfd);
# 1630|   		if (n <= 0 || (unsigned)n >= sizeof(buf))
# 1631|   			continue;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def124]
mdadm-4.3/util.c:1743:18: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(dev, 130)’
mdadm-4.3/util.c:1735:14: acquire_resource: opened here
mdadm-4.3/util.c:1736:12: branch_false: following ‘false’ branch...
mdadm-4.3/util.c:1743:18: branch_false: ...to here
mdadm-4.3/util.c:1743:18: throw: if ‘fd2devnm’ throws an exception...
mdadm-4.3/util.c:1743:18: danger: ‘open(dev, 130)’ leaks here; was opened at [(1)](sarif:/runs/0/results/5/codeFlows/0/threadFlows/0/locations/0)
# 1741|   	}
# 1742|   
# 1743|-> 	_devnm = fd2devnm(fd);
# 1744|   	if (_devnm == NULL) {
# 1745|   		if (!quiet)

Error: GCC_ANALYZER_WARNING (CWE-775): [#def125]
mdadm-4.3/util.c:2017:17: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open("/dev/urandom", 0)’
mdadm-4.3/util.c:2015:19: acquire_resource: opened here
mdadm-4.3/util.c:2016:12: branch_false: following ‘false’ branch...
mdadm-4.3/util.c:2016:24: branch_false: ...to here
mdadm-4.3/util.c:2016:13: branch_true: following ‘true’ branch...
mdadm-4.3/util.c:2017:22: branch_true: ...to here
mdadm-4.3/util.c:2018:12: branch_true: following ‘true’ branch...
mdadm-4.3/util.c:2019:17: branch_true: ...to here
mdadm-4.3/util.c:2017:17: danger: ‘open("/dev/urandom", 0)’ leaks here; was opened at [(1)](sarif:/runs/0/results/6/codeFlows/0/threadFlows/0/locations/0)
# 2015|   	int rfd = open("/dev/urandom", O_RDONLY);
# 2016|   	if (rfd < 0 || read(rfd, &rv, 4) != 4)
# 2017|-> 		rv = random();
# 2018|   	if (rfd >= 0)
# 2019|   		close(rfd);

Error: GCC_ANALYZER_WARNING (CWE-775): [#def126]
mdadm-4.3/util.c:2019:17: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open("/dev/urandom", 0)’
mdadm-4.3/util.c:2015:19: acquire_resource: opened here
mdadm-4.3/util.c:2016:12: branch_false: following ‘false’ branch...
mdadm-4.3/util.c:2018:12: branch_true: following ‘true’ branch...
mdadm-4.3/util.c:2019:17: branch_true: ...to here
mdadm-4.3/util.c:2019:17: danger: ‘open("/dev/urandom", 0)’ leaks here; was opened at [(1)](sarif:/runs/0/results/7/codeFlows/0/threadFlows/0/locations/0)
# 2017|   		rv = random();
# 2018|   	if (rfd >= 0)
# 2019|-> 		close(rfd);
# 2020|   	return rv;
# 2021|   }

Error: GCC_ANALYZER_WARNING (CWE-775): [#def127]
mdadm-4.3/util.c:2032:9: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open("/dev/urandom", 0)’
mdadm-4.3/util.c:2028:14: acquire_resource: opened here
mdadm-4.3/util.c:2029:12: branch_false: following ‘false’ branch...
mdadm-4.3/util.c:2031:15: branch_false: ...to here
mdadm-4.3/util.c:2032:9: danger: ‘open("/dev/urandom", 0)’ leaks here; was opened at [(1)](sarif:/runs/0/results/8/codeFlows/0/threadFlows/0/locations/0)
# 2030|   		goto use_random;
# 2031|   	len = read(fd, buf, 16);
# 2032|-> 	close(fd);
# 2033|   	if (len != 16)
# 2034|   		goto use_random;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def128]
mdadm-4.3/util.c:2211:9: warning[-Wanalyzer-fd-leak]: leak of file descriptor
# 2209|   
# 2210|   	close(0);
# 2211|-> 	open("/dev/null", O_RDWR);
# 2212|   
# 2213|   #ifndef DEBUG

Error: GCC_ANALYZER_WARNING (CWE-910): [#def129]
mdadm-4.3/util.c:2214:9: warning[-Wanalyzer-fd-use-after-close]: ‘dup2’ on closed file descriptor ‘0’
mdadm-4.3/util.c:2210:9: release_resource: closed here
mdadm-4.3/util.c:2214:9: danger: ‘dup2’ on closed file descriptor ‘0’; ‘close’ was at [(1)](sarif:/runs/0/results/10/codeFlows/0/threadFlows/0/locations/0)
# 2212|   
# 2213|   #ifndef DEBUG
# 2214|-> 	dup2(0, 1);
# 2215|   	dup2(0, 2);
# 2216|   #endif

Error: GCC_ANALYZER_WARNING (CWE-910): [#def130]
mdadm-4.3/util.c:2215:9: warning[-Wanalyzer-fd-use-after-close]: ‘dup2’ on closed file descriptor ‘0’
mdadm-4.3/util.c:2210:9: release_resource: closed here
mdadm-4.3/util.c:2215:9: danger: ‘dup2’ on closed file descriptor ‘0’; ‘close’ was at [(1)](sarif:/runs/0/results/11/codeFlows/0/threadFlows/0/locations/0)
# 2213|   #ifndef DEBUG
# 2214|   	dup2(0, 1);
# 2215|-> 	dup2(0, 2);
# 2216|   #endif
# 2217|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def131]
mdadm-4.3/util.c:2226:23: warning[-Wanalyzer-malloc-leak]: leak of ‘opendir("/proc/self/fd")’
mdadm-4.3/util.c:2221:15: acquire_memory: allocated here
mdadm-4.3/util.c:2222:12: branch_false: following ‘false’ branch...
mdadm-4.3/util.c:2226:23: branch_false: ...to here
mdadm-4.3/util.c:2226:23: throw: if ‘readdir’ throws an exception...
mdadm-4.3/util.c:2226:23: danger: ‘opendir("/proc/self/fd")’ leaks here; was allocated at [(1)](sarif:/runs/0/results/12/codeFlows/0/threadFlows/0/locations/0)
# 2224|   		return;
# 2225|   	}
# 2226|-> 	for (dirent = readdir(dir); dirent; dirent = readdir(dir)) {
# 2227|   		int fd = -1;
# 2228|   

Error: GCC_ANALYZER_WARNING (CWE-775): [#def132]
mdadm-4.3/util.c:2390:25: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open("/dev/zero", 0)’
mdadm-4.3/util.c:2384:19: acquire_resource: opened here
mdadm-4.3/util.c:2385:12: branch_false: following ‘false’ branch...
mdadm-4.3/util.c:2390:25: branch_false: ...to here
mdadm-4.3/util.c:2390:12: branch_true: following ‘true’ branch...
mdadm-4.3/util.c:2391:24: branch_true: ...to here
mdadm-4.3/util.c:2390:25: danger: ‘open("/dev/zero", 0)’ leaks here; was opened at [(1)](sarif:/runs/0/results/13/codeFlows/0/threadFlows/0/locations/0)
# 2388|   	}
# 2389|   
# 2390|-> 	if (lseek64(fd, sector * 512, SEEK_SET) < 0) {
# 2391|   		ret = -errno;
# 2392|   		pr_err("Failed to seek offset for zeroing\n");

Scan Properties

analyzer-version-clippy1.92.0
analyzer-version-cppcheck2.19.1
analyzer-version-gcc16.0.0
analyzer-version-gcc-analyzer16.0.0
analyzer-version-shellcheck0.11.0
analyzer-version-unicontrol0.0.2
enabled-pluginsclippy, cppcheck, gcc, shellcheck, unicontrol
exit-code0
hostip-172-16-1-225.us-west-2.compute.internal
known-false-positives/usr/share/csmock/known-false-positives.js
known-false-positives-rpmknown-false-positives-0.0.0.20250521.132812.g8eff701.main-1.el9.noarch
mock-configfedora-rawhide-x86_64
project-namemdadm-4.3-9.fc44
store-results-to/tmp/tmpckcnfvzc/mdadm-4.3-9.fc44.tar.xz
time-created2026-01-08 19:33:25
time-finished2026-01-08 19:35:15
toolcsmock
tool-args'/usr/bin/csmock' '-r' 'fedora-rawhide-x86_64' '-t' 'gcc,cppcheck,clippy,shellcheck,unicontrol' '-o' '/tmp/tmpckcnfvzc/mdadm-4.3-9.fc44.tar.xz' '--gcc-analyze' '--unicontrol-notests' '--unicontrol-bidi-only' '--install' 'pam' '--gcc-analyzer-bin=/usr/bin/gcc' '/tmp/tmpckcnfvzc/mdadm-4.3-9.fc44.src.rpm'
tool-versioncsmock-3.8.3.20251215.161544.g62de9a5-1.el9