DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	Stephen Hemminger <sthemmin@microsoft.com>
Subject: [dpdk-dev] [PATCH 3/3] vmbus: handle eof on irq read
Date: Mon,  6 Aug 2018 11:11:08 -0700	[thread overview]
Message-ID: <20180806181108.5913-4-stephen@networkplumber.org> (raw)
In-Reply-To: <20180806181108.5913-1-stephen@networkplumber.org>

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 <sthemmin@microsoft.com>
---
 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 bc2c6235e6bc..856c6d66785d 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.18.0

  parent reply	other threads:[~2018-08-06 18:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-06 18:11 [dpdk-dev] [PATCH 0/3] vmbus: coverity bug fixes Stephen Hemminger
2018-08-06 18:11 ` [dpdk-dev] [PATCH 1/3] vmbus: close directory in error path Stephen Hemminger
2018-08-06 18:11 ` [dpdk-dev] [PATCH 2/3] vmbus: make sure path is null terminated Stephen Hemminger
2018-08-06 18:11 ` Stephen Hemminger [this message]
2018-08-07 11:26 ` [dpdk-dev] [PATCH 0/3] vmbus: coverity bug fixes Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180806181108.5913-4-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=sthemmin@microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).