]> git.proxmox.com Git - mirror_zfs.git/commitdiff
kobj_read_file: Return -1 on vn_rdwr() error
authorRichard Yao <richard.yao@clusterhq.com>
Sat, 12 Dec 2015 00:47:47 +0000 (19:47 -0500)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Sat, 23 Jan 2016 18:16:26 +0000 (10:16 -0800)
LLVM's static analyzer showed that we could subtract using an
uninitialized value on an error from vn_rdwr().

The correct behavior is to return -1 on an error, so lets do that
instead.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4104

lib/libzpool/kernel.c

index 6ed08bdb0a6962b799587c1dd8f33356fe159f04..a69a8da3aeeb9abbce1477133198d59cb835df73 100644 (file)
@@ -997,8 +997,9 @@ kobj_read_file(struct _buf *file, char *buf, unsigned size, unsigned off)
 {
        ssize_t resid;
 
-       vn_rdwr(UIO_READ, (vnode_t *)file->_fd, buf, size, (offset_t)off,
-           UIO_SYSSPACE, 0, 0, 0, &resid);
+       if (vn_rdwr(UIO_READ, (vnode_t *)file->_fd, buf, size, (offset_t)off,
+           UIO_SYSSPACE, 0, 0, 0, &resid) != 0)
+               return (-1);
 
        return (size - resid);
 }