]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdadm/mdmon: fix coverity issue CHECKED_RETURN
authorXiao Ni <xni@redhat.com>
Fri, 26 Jul 2024 07:14:07 +0000 (15:14 +0800)
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Mon, 5 Aug 2024 09:08:46 +0000 (11:08 +0200)
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>
mdmon.c

diff --git a/mdmon.c b/mdmon.c
index 95e350f4ab00d9d13fb1bdadf540f0b68861d153..cae6384140c2870d4427d3be9b132202068cd39e 100644 (file)
--- 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;
 }