btrfs-progs: fix double file descriptor close in cmd_replace_start()

Reported by 'gcc -fanalyzer':
cmds/replace.c:357:17: warning: double ‘close’ of file descriptor ‘fdmnt’ [CWE-1341] [-Wanalyzer-fd-double-close]

The first close is done right before going to the label
'leave_with_error' but the variable is not reset to -1 so in the exit
block close() is called again.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2024-04-04 00:42:23 +02:00
parent 0e3614e8f9
commit 2bdb838d54

View file

@ -199,7 +199,6 @@ static int cmd_replace_start(const struct cmd_struct *cmd,
if (ret != 0) {
if (ret < 0)
error("unable to check status of exclusive operation: %m");
close(fdmnt);
goto leave_with_error;
}