From cd3e20a687032afa31752ef02a2c7bca9ce6108d Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 6 Aug 2018 11:11:08 -0700 Subject: [PATCH] bus/vmbus: handle EOF on IRQ read This function is not used by netvsc driver yet. Still the code should handle case where device driver returns zero (due to rescind). Coverity issue: 302871 Fixes: 831dba47bd36 ("bus/vmbus: add Hyper-V virtual bus support") Signed-off-by: Stephen Hemminger --- drivers/bus/vmbus/linux/vmbus_uio.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/bus/vmbus/linux/vmbus_uio.c b/drivers/bus/vmbus/linux/vmbus_uio.c index bc2c6235e6..856c6d6678 100644 --- a/drivers/bus/vmbus/linux/vmbus_uio.c +++ b/drivers/bus/vmbus/linux/vmbus_uio.c @@ -39,11 +39,17 @@ void vmbus_uio_irq_control(struct rte_vmbus_device *dev, int32_t onoff) int vmbus_uio_irq_read(struct rte_vmbus_device *dev) { int32_t count; - - if (read(dev->intr_handle.fd, &count, sizeof(count)) < 0) { - VMBUS_LOG(ERR, "cannot read to %d:%s", - dev->intr_handle.fd, strerror(errno)); - count = -errno; + int cc; + + cc = read(dev->intr_handle.fd, &count, sizeof(count)); + if (cc < (int)sizeof(count)) { + if (cc < 0) { + VMBUS_LOG(ERR, "IRQ read failed %s", + strerror(errno)); + return -errno; + } + VMBUS_LOG(ERR, "can't read IRQ count"); + return -EINVAL; } return count; -- 2.20.1