diff options
author | Xiao Ni <xni@redhat.com> | 2024-07-26 09:14:11 +0200 |
---|---|---|
committer | Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> | 2024-08-05 11:13:17 +0200 |
commit | 6984814b6fd879efae178acb057c1025aa4c64e8 (patch) | |
tree | e2992b715f7674e1ce2e0371a73ced3e331096cf | |
parent | mdadm/mdopen: fix coverity issue STRING_OVERFLOW (diff) | |
download | mdadm-6984814b6fd879efae178acb057c1025aa4c64e8.tar.xz mdadm-6984814b6fd879efae178acb057c1025aa4c64e8.zip |
mdadm/mdstat: fix coverity issue CHECKED_RETURN
It needs to check return values when functions return value.
Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
-rw-r--r-- | mdstat.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -194,8 +194,11 @@ struct mdstat_ent *mdstat_read(int hold, int start) f = fopen("/proc/mdstat", "r"); if (f == NULL) return NULL; - else - fcntl(fileno(f), F_SETFD, FD_CLOEXEC); + + if (fcntl(fileno(f), F_SETFD, FD_CLOEXEC) < 0) { + fclose(f); + return NULL; + } all = NULL; end = &all; @@ -329,7 +332,10 @@ struct mdstat_ent *mdstat_read(int hold, int start) } if (hold && mdstat_fd == -1) { mdstat_fd = dup(fileno(f)); - fcntl(mdstat_fd, F_SETFD, FD_CLOEXEC); + if (fcntl(mdstat_fd, F_SETFD, FD_CLOEXEC) < 0) { + fclose(f); + return NULL; + } } fclose(f); |