summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNigel Croxon <ncroxon@redhat.com>2024-07-24 15:04:08 +0200
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>2024-07-30 16:05:47 +0200
commit2a4c40766d654dcbf5911d1b7b63bbbe8b2c0128 (patch)
tree7c8881aade47df5d5a09c255fb298d79c69d18e3
parentmdstat: Rework mdstat external arrays handling (diff)
downloadmdadm-2a4c40766d654dcbf5911d1b7b63bbbe8b2c0128.tar.xz
mdadm-2a4c40766d654dcbf5911d1b7b63bbbe8b2c0128.zip
mdadm: managemon.c fix coverity issues
Fixing the following coding errors the coverity tools found: * Event check_return: Calling "fcntl(fd, 4, fl)" without checking return value. This library function may fail and return an error code. * Event check_after_deref: Null-checking "new" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
-rw-r--r--managemon.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/managemon.c b/managemon.c
index 358459e7..add6a79e 100644
--- a/managemon.c
+++ b/managemon.c
@@ -776,10 +776,8 @@ static void manage_new(struct mdstat_ent *mdstat,
error:
pr_err("failed to monitor %s\n", mdstat->metadata_version);
- if (new) {
- new->container = NULL;
- free_aa(new);
- }
+ new->container = NULL;
+ free_aa(new);
if (mdi)
sysfs_free(mdi);
}
@@ -870,8 +868,15 @@ void read_sock(struct supertype *container)
return;
fl = fcntl(fd, F_GETFL, 0);
+ if (fl < 0) {
+ close_fd(&fd);
+ return;
+ }
fl |= O_NONBLOCK;
- fcntl(fd, F_SETFL, fl);
+ if (fcntl(fd, F_SETFL, fl) < 0) {
+ close_fd(&fd);
+ return;
+ }
do {
msg.buf = NULL;