From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [dpdk-dev] [RFC] ethdev: check for invalid device name
Date: Wed, 6 Mar 2019 09:43:17 -0800 [thread overview]
Message-ID: <20190306174317.14164-1-stephen@networkplumber.org> (raw)
Do not allow creating a ethernet device with a name over the
allowed maximum (or 0 length).
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/librte_ethdev/rte_ethdev.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 85c1794968dd..0b81980ff71c 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -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. */
--
2.17.1
next reply other threads:[~2019-03-06 17:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-06 17:43 Stephen Hemminger [this message]
2019-03-11 10:15 ` Andrew Rybchenko
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=20190306174317.14164-1-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
/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).