Skip to content

Commit

Permalink
kobj_read_file: Return -1 on vn_rdwr() error
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ryao committed Dec 15, 2015
1 parent 799402d commit d722714
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/libzpool/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit d722714

Please sign in to comment.