mdadm/0134-mdadm-managemon.c-fix-coverity-issues.patch
Xiao Ni f1b7707f26 Update to latest upstream
For issue RHEL-40729, patch 0142 fixes it.
For issue RHEL-31448, patch 0125 fixes it.

Resolves: RHEL-31448,RHEL-40729,RHEL-52059

Signed-off-by: Xiao Ni <xni@redhat.com>
2024-10-19 05:22:07 -04:00

57 lines
1.4 KiB
Diff

From 2a4c40766d654dcbf5911d1b7b63bbbe8b2c0128 Mon Sep 17 00:00:00 2001
From: Nigel Croxon <ncroxon@redhat.com>
Date: Wed, 24 Jul 2024 09:04:08 -0400
Subject: [PATCH 134/201] 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>
---
managemon.c | 15 ++++++++++-----
1 file 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;
--
2.41.0