device-mapper-multipath/SOURCES/0032-kpartx-fail-if-dup-of-...

31 lines
854 B
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Benjamin Marzinski <bmarzins@redhat.com>
Date: Thu, 16 May 2019 12:55:16 -0500
Subject: [PATCH] kpartx: fail if dup() of dasd file descriptor fails
If kpartx fails to create a copy of the dasd file descriptor, it should
fail, instead of treating the error value as a valid fd. Found by
coverity.
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
kpartx/dasd.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kpartx/dasd.c b/kpartx/dasd.c
index 61b609a..d95d8ca 100644
--- a/kpartx/dasd.c
+++ b/kpartx/dasd.c
@@ -138,6 +138,8 @@ read_dasd_pt(int fd, struct slice all, struct slice *sp, int ns)
return -1;
} else {
fd_dasd = dup(fd);
+ if (fd_dasd < 0)
+ return -1;
}
if (ioctl(fd_dasd, BIODASDINFO, (unsigned long)&info) != 0) {
--
2.17.2