[dm-devel] [PATCH 2/4] kpartx: fail if dup() of dasd file descriptor fails

Benjamin Marzinski bmarzins at redhat.com
Fri May 17 16:14:08 UTC 2019


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 at redhat.com>
---
 kpartx/dasd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kpartx/dasd.c b/kpartx/dasd.c
index 61b609a5..d95d8ca0 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




More information about the dm-devel mailing list