You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.1 KiB
47 lines
1.1 KiB
2 months ago
|
From 6984814b6fd879efae178acb057c1025aa4c64e8 Mon Sep 17 00:00:00 2001
|
||
|
From: Xiao Ni <xni@redhat.com>
|
||
|
Date: Fri, 26 Jul 2024 15:14:11 +0800
|
||
|
Subject: [PATCH 145/157] 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>
|
||
|
---
|
||
|
mdstat.c | 12 +++++++++---
|
||
|
1 file changed, 9 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/mdstat.c b/mdstat.c
|
||
|
index cbbace3d..a971a957 100644
|
||
|
--- a/mdstat.c
|
||
|
+++ b/mdstat.c
|
||
|
@@ -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);
|
||
|
|
||
|
--
|
||
|
2.41.0
|
||
|
|