kpartx: fail if dup() of dasd file descriptor fails
authorBenjamin Marzinski <bmarzins@redhat.com>
Fri, 17 May 2019 16:14:08 +0000 (11:14 -0500)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Wed, 3 Jul 2019 06:03:50 +0000 (08:03 +0200)
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

index 61b609a..d95d8ca 100644 (file)
@@ -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) {