summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXiao Ni <xni@redhat.com>2024-07-26 09:14:07 +0200
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>2024-08-05 11:08:46 +0200
commitf9949a04355f0fca29c6bc02ead8425e76daa573 (patch)
treeb6a45dd6ac22f2fa68268cd97787e958eea0c6c7
parentmdadm/Incremental: fix coverity issues. (diff)
downloadmdadm-f9949a04355f0fca29c6bc02ead8425e76daa573.tar.xz
mdadm-f9949a04355f0fca29c6bc02ead8425e76daa573.zip
mdadm/mdmon: fix coverity issue CHECKED_RETURN
It needs to check return values when functions have return value. Signed-off-by: Xiao Ni <xni@redhat.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
-rw-r--r--mdmon.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/mdmon.c b/mdmon.c
index 95e350f4..cae63841 100644
--- a/mdmon.c
+++ b/mdmon.c
@@ -198,8 +198,12 @@ static void try_kill_monitor(pid_t pid, char *devname, int sock)
/* Wait for monitor to exit by reading from the socket, after
* clearing the non-blocking flag */
fl = fcntl(sock, F_GETFL, 0);
+ if (fl < 0)
+ return;
+
fl &= ~O_NONBLOCK;
- fcntl(sock, F_SETFL, fl);
+ if (fcntl(sock, F_SETFL, fl) < 0)
+ return;
n = read(sock, buf, 100);
/* If there is I/O going on it might took some time to get to
@@ -249,7 +253,10 @@ static int make_control_sock(char *devname)
listen(sfd, 10);
fl = fcntl(sfd, F_GETFL, 0);
fl |= O_NONBLOCK;
- fcntl(sfd, F_SETFL, fl);
+ if (fcntl(sfd, F_SETFL, fl) < 0) {
+ close_fd(&sfd);
+ return -1;
+ }
return sfd;
}