DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/3] vmbus: coverity bug fixes
@ 2018-08-06 18:11 Stephen Hemminger
  2018-08-06 18:11 ` [dpdk-dev] [PATCH 1/3] vmbus: close directory in error path Stephen Hemminger
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Stephen Hemminger @ 2018-08-06 18:11 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Recent Covertity scan reported some issues in code that is
unlikely to be used, but fix it anyway.

Stephen Hemminger (3):
  vmbus: close directory in error path
  vmbus: make sure path is null terminated
  vmbus: handle eof on irq read

 drivers/bus/vmbus/linux/vmbus_uio.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

-- 
2.18.0

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-dev] [PATCH 1/3] vmbus: close directory in error path
  2018-08-06 18:11 [dpdk-dev] [PATCH 0/3] vmbus: coverity bug fixes Stephen Hemminger
@ 2018-08-06 18:11 ` Stephen Hemminger
  2018-08-06 18:11 ` [dpdk-dev] [PATCH 2/3] vmbus: make sure path is null terminated Stephen Hemminger
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2018-08-06 18:11 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Stephen Hemminger

Fix bug reported by Coverity where directory being scanned was
not closed in error path (leaking file descriptor).

Coverity issue: 302848
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 | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/bus/vmbus/linux/vmbus_uio.c b/drivers/bus/vmbus/linux/vmbus_uio.c
index b0f8ebaea6ea..0b1b153cc017 100644
--- a/drivers/bus/vmbus/linux/vmbus_uio.c
+++ b/drivers/bus/vmbus/linux/vmbus_uio.c
@@ -357,6 +357,7 @@ int vmbus_uio_get_subchan(struct vmbus_channel *primary,
 		if (err) {
 			VMBUS_LOG(NOTICE, "invalid subchannel id %lu",
 				  subid);
+			closedir(chan_dir);
 			return err;
 		}
 
-- 
2.18.0

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-dev] [PATCH 2/3] vmbus: make sure path is null terminated
  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 ` Stephen Hemminger
  2018-08-06 18:11 ` [dpdk-dev] [PATCH 3/3] vmbus: handle eof on irq read Stephen Hemminger
  2018-08-07 11:26 ` [dpdk-dev] [PATCH 0/3] vmbus: coverity bug fixes Thomas Monjalon
  3 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2018-08-06 18:11 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Stephen Hemminger

Use strlcpy rather than strncpy to avoid any issues about
null termination.

Coverity issue 302859
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 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/vmbus/linux/vmbus_uio.c b/drivers/bus/vmbus/linux/vmbus_uio.c
index 0b1b153cc017..bc2c6235e6bc 100644
--- a/drivers/bus/vmbus/linux/vmbus_uio.c
+++ b/drivers/bus/vmbus/linux/vmbus_uio.c
@@ -18,6 +18,7 @@
 #include <rte_common.h>
 #include <rte_malloc.h>
 #include <rte_bus_vmbus.h>
+#include <rte_string_fns.h>
 
 #include "private.h"
 
@@ -89,7 +90,7 @@ vmbus_uio_alloc_resource(struct rte_vmbus_device *dev,
 		goto error;
 	}
 
-	strncpy((*uio_res)->path, devname, PATH_MAX);
+	strlcpy((*uio_res)->path, devname, PATH_MAX);
 	rte_uuid_copy((*uio_res)->id, dev->device_id);
 
 	return 0;
-- 
2.18.0

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-dev] [PATCH 3/3] vmbus: handle eof on irq read
  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
  2018-08-07 11:26 ` [dpdk-dev] [PATCH 0/3] vmbus: coverity bug fixes Thomas Monjalon
  3 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2018-08-06 18:11 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Stephen Hemminger

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH 0/3] vmbus: coverity bug fixes
  2018-08-06 18:11 [dpdk-dev] [PATCH 0/3] vmbus: coverity bug fixes Stephen Hemminger
                   ` (2 preceding siblings ...)
  2018-08-06 18:11 ` [dpdk-dev] [PATCH 3/3] vmbus: handle eof on irq read Stephen Hemminger
@ 2018-08-07 11:26 ` Thomas Monjalon
  3 siblings, 0 replies; 5+ messages in thread
From: Thomas Monjalon @ 2018-08-07 11:26 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

06/08/2018 20:11, Stephen Hemminger:
> Recent Covertity scan reported some issues in code that is
> unlikely to be used, but fix it anyway.
> 
> Stephen Hemminger (3):
>   vmbus: close directory in error path
>   vmbus: make sure path is null terminated
>   vmbus: handle eof on irq read

Applied, thanks

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-08-07 11:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [dpdk-dev] [PATCH 3/3] vmbus: handle eof on irq read Stephen Hemminger
2018-08-07 11:26 ` [dpdk-dev] [PATCH 0/3] vmbus: coverity bug fixes Thomas Monjalon

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).