From d722714db8158b06d61f2da61524e784d02b98d6 Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Fri, 11 Dec 2015 19:47:47 -0500 Subject: [PATCH] kobj_read_file: Return -1 on vn_rdwr() error 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 --- lib/libzpool/kernel.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/libzpool/kernel.c b/lib/libzpool/kernel.c index a451026999c5..f291d8ebeeac 100644 --- a/lib/libzpool/kernel.c +++ b/lib/libzpool/kernel.c @@ -966,8 +966,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); }