From 2bdb838d549bb81cc441c9b0a834f0143dd9c1ce Mon Sep 17 00:00:00 2001 From: David Sterba Date: Thu, 4 Apr 2024 00:42:23 +0200 Subject: [PATCH] btrfs-progs: fix double file descriptor close in cmd_replace_start() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- cmds/replace.c | 1 - 1 file changed, 1 deletion(-) diff --git a/cmds/replace.c b/cmds/replace.c index 05e5f814..c1eec84c 100644 --- a/cmds/replace.c +++ b/cmds/replace.c @@ -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; }