Thread (12 messages) 12 messages, 2 authors, 2015-11-04
STALE3860d

[PATCH 3/3] ethdev: prevent segfaults in rte_eth_dev_is_detachable

From: David Marchand <hidden>
Date: 2015-10-29 08:55:13
Subsystem: library code, the rest · Maintainers: Andrew Morton, Linus Torvalds

From: Maxime Leroy <redacted>

Some drivers like virtual ones don't specify any driver pointer in the
structure rte_eth_dev.

To prevent segfault, we should check if this pointer is NULL before
dereferencing it.

Signed-off-by: Maxime Leroy <redacted>
Signed-off-by: David Marchand <redacted>
---
 lib/librte_ether/rte_ethdev.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 7fa5717..750e4b5 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -522,6 +522,9 @@ rte_eth_dev_is_detachable(uint8_t port_id)
 		}
 	}
 
+	if (rte_eth_devices[port_id].driver == NULL)
+		return 0;
+
 	drv_flags = rte_eth_devices[port_id].driver->pci_drv.drv_flags;
 	return drv_flags & RTE_PCI_DRV_DETACHABLE;
 }
-- 
1.9.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help