]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdadm: msg.c fix coverity issues
authorNigel Croxon <ncroxon@redhat.com>
Wed, 24 Jul 2024 13:20:28 +0000 (09:20 -0400)
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Tue, 30 Jul 2024 14:06:45 +0000 (16:06 +0200)
Fixing the following coding errors the coverity tools found:

* Event check_return: Calling "fcntl(sfd, 4, fl)" without
checking return value. This library function may fail and
return an error code.

Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
msg.c

diff --git a/msg.c b/msg.c
index f0772b3f90bfd3943d871210a45abd46084f6542..b6da91d387e0767fce2241bd28069ea92d0f90a2 100644 (file)
--- a/msg.c
+++ b/msg.c
@@ -176,8 +176,15 @@ int connect_monitor(char *devname)
        }
 
        fl = fcntl(sfd, F_GETFL, 0);
+       if (fl < 0) {
+               close(sfd);
+               return -1;
+       }
        fl |= O_NONBLOCK;
-       fcntl(sfd, F_SETFL, fl);
+       if (fcntl(sfd, F_SETFL, fl) < 0) {
+               close(sfd);
+               return -1;
+       }
 
        return sfd;
 }