DPDK patches and discussions
 help / color / mirror / Atom feed
From: Mohammad Abdul Awal <mohammad.abdul.awal@intel.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, ferruh.yigit@intel.com,
	arybchenko@solarflare.com,
	Mohammad Abdul Awal <mohammad.abdul.awal@intel.com>,
	stable@dpdk.org
Subject: [dpdk-dev] [PATCH 1/3] ethdev: fix null pointer checking
Date: Wed,  3 Apr 2019 17:07:26 +0100	[thread overview]
Message-ID: <20190403160726.1231-1-mohammad.abdul.awal@intel.com> (raw)
Message-ID: <20190403160726.tNN7kOSE22Q0xIjlYd-xBlc4M-5aKIonLx_EDUHdpoA@z> (raw)

Null value for parameter name will cause segfault for the
strnlen and strcmp functions.

Fixes: 0b33b68d12 ("ethdev: export allocate function")
Fixes: 942661004c ("ethdev: export secondary attach function")
Cc: stable@dpdk.org

Signed-off-by: Mohammad Abdul Awal <mohammad.abdul.awal@intel.com>
---
 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 10bdfb37e..26898ed08 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -440,6 +440,11 @@ rte_eth_dev_allocate(const char *name)
 	struct rte_eth_dev *eth_dev = NULL;
 	size_t name_len;
 
+	if (name == NULL) {
+		RTE_ETHDEV_LOG(ERR, "Null pointer is specified\n");
+		return NULL;
+	}
+
 	name_len = strnlen(name, RTE_ETH_NAME_MAX_LEN);
 	if (name_len == 0) {
 		RTE_ETHDEV_LOG(ERR, "Zero length Ethernet device name\n");
@@ -492,6 +497,11 @@ rte_eth_dev_attach_secondary(const char *name)
 	uint16_t i;
 	struct rte_eth_dev *eth_dev = NULL;
 
+	if (name == NULL) {
+		RTE_ETHDEV_LOG(ERR, "Null pointer is specified\n");
+		return NULL;
+	}
+
 	rte_eth_dev_shared_data_prepare();
 
 	/* Synchronize port attachment to primary port creation and release. */
-- 
2.17.1


             reply	other threads:[~2019-04-03 16:08 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-03 16:07 Mohammad Abdul Awal [this message]
2019-04-03 16:07 ` Mohammad Abdul Awal
2019-04-03 16:27 ` Thomas Monjalon
2019-04-03 16:27   ` Thomas Monjalon
2019-04-03 16:35   ` Ferruh Yigit
2019-04-03 16:35     ` Ferruh Yigit
2019-04-03 16:41     ` Bruce Richardson
2019-04-03 16:41       ` Bruce Richardson
2019-04-03 16:52       ` Ferruh Yigit
2019-04-03 16:52         ` Ferruh Yigit
2019-04-03 17:32         ` David Marchand
2019-04-03 17:32           ` David Marchand
2019-04-04  8:33           ` Mohammad Abdul Awal
2019-04-04  8:33             ` Mohammad Abdul Awal
2019-04-03 17:30     ` Awal, Mohammad Abdul
2019-04-03 17:30       ` Awal, Mohammad Abdul
2019-04-03 18:42       ` Thomas Monjalon
2019-04-03 18:42         ` Thomas Monjalon
2019-04-03 18:50 ` Stephen Hemminger
2019-04-03 18:50   ` Stephen Hemminger

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=20190403160726.1231-1-mohammad.abdul.awal@intel.com \
    --to=mohammad.abdul.awal@intel.com \
    --cc=arybchenko@solarflare.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    /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).