diff options
author | Xiao Ni <xni@redhat.com> | 2024-07-26 09:14:08 +0200 |
---|---|---|
committer | Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> | 2024-08-05 11:11:59 +0200 |
commit | e7623d5ae4724c72e873e8af17f2ed6bfdc54427 (patch) | |
tree | f87785d17d5273139996a9203cbc402a49f8c0bb | |
parent | mdadm/mdmon: fix coverity issue CHECKED_RETURN (diff) | |
download | mdadm-e7623d5ae4724c72e873e8af17f2ed6bfdc54427.tar.xz mdadm-e7623d5ae4724c72e873e8af17f2ed6bfdc54427.zip |
mdadm/mdmon: fix coverity issue RESOURCE_LEAK
Fix resource leak problem in mdmon.c
Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
-rw-r--r-- | mdmon.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -456,22 +456,25 @@ 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_fd(&mdfd); return 1; } switch(fork()) { case -1: pr_err("failed to fork: %s\n", strerror(errno)); + close_fd(&mdfd); return 1; case 0: /* child */ - close(pfd[0]); + close_fd(&pfd[0]); break; default: /* parent */ - close(pfd[1]); + close_fd(&pfd[1]); if (read(pfd[0], &status, sizeof(status)) != sizeof(status)) { wait(&status); status = WEXITSTATUS(status); } - close(pfd[0]); + close_fd(&pfd[0]); + close_fd(&mdfd); return status; } } else |