diff mbox series

[07/15] mdadm/mdmon: fix coverity issue RESOURCE_LEAK

Message ID 20240715073604.30307-8-xni@redhat.com (mailing list archive)
State Superseded
Headers show
Series mdadm: fix coverity issues | expand

Checks

Context Check Description
mdraidci/vmtest-md-6_11-PR fail merge-conflict

Commit Message

Xiao Ni July 15, 2024, 7:35 a.m. UTC
Signed-off-by: Xiao Ni <xni@redhat.com>
---
 mdmon.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/mdmon.c b/mdmon.c
index b8f71e5db555..f0e89924aef7 100644
--- a/mdmon.c
+++ b/mdmon.c
@@ -455,11 +455,13 @@  static int mdmon(char *devnm, int must_fork, int takeover)
 	if (must_fork) {
 		if (pipe(pfd) != 0) {
 			pr_err("failed to create pipe\n");
+			close(mdfd);
 			return 1;
 		}
 		switch(fork()) {
 		case -1:
 			pr_err("failed to fork: %s\n", strerror(errno));
+			close(mdfd);
 			return 1;
 		case 0: /* child */
 			close(pfd[0]);
@@ -471,6 +473,7 @@  static int mdmon(char *devnm, int must_fork, int takeover)
 				status = WEXITSTATUS(status);
 			}
 			close(pfd[0]);
+			close(mdfd);
 			return status;
 		}
 	} else