ethdev: check for invalid device name
RFC 1/1 ethdev: check for invalid device name
Do not allow creating a ethernet device with a name over the allowed maximum (or 0 length).
Signed-off-by Stephen Hemminger <[email protected]>
--- lib/librte_ethdev/rte_ethdev.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
lib/librte_ethdev/rte_ethdev.c +10 -0
@@ -439,6 +439,16 @@ rte_eth_dev_allocate(const char *name)uint16_t port_id;struct rte_eth_dev *eth_dev =NULL ; +if (*name) { +RTE_ETHDEV_LOG (ERR ,"Zero length Ethernet device name\n" ); +return NULL ; + } + +if (strnlen (name,RTE_ETH_NAME_MAX_LEN ) >=RTE_ETH_NAME_MAX_LEN ) { +RTE_ETHDEV_LOG (ERR ,"Ethernet device name is too long\n" ); +return NULL ; + } +rte_eth_dev_shared_data_prepare ();/* Synchronize port creation between primary and secondary threads. */
Signature · 1 line
2.17.1
Quoted 4 lines · Stephen Hemminger
Do not allow creating a ethernet device with a name over the allowed maximum (or 0 length).
Signed-off-by Stephen Hemminger <[email protected]>
Acked-by Andrew Rybchenko <[email protected]>