From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: [PATCH 1/3] ethdev: fix null pointer checking Date: Wed, 03 Apr 2019 18:27:51 +0200 Message-ID: <1807422.QXMQecOh3y@xps> References: <20190403160726.1231-1-mohammad.abdul.awal@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Cc: dev@dpdk.org, ferruh.yigit@intel.com, arybchenko@solarflare.com, stable@dpdk.org To: Mohammad Abdul Awal Return-path: In-Reply-To: <20190403160726.1231-1-mohammad.abdul.awal@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 03/04/2019 18:07, Mohammad Abdul Awal: > Null value for parameter name will cause segfault for the > strnlen and strcmp functions. I'm not sure we want such obvious checks for all APIs. Here I would say yes. > Fixes: 0b33b68d12 ("ethdev: export allocate function") > Fixes: 942661004c ("ethdev: export secondary attach function") > Cc: stable@dpdk.org > > Signed-off-by: Mohammad Abdul Awal > --- > --- 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"); This is a very generic error message. It might be "Fail to allocate port with empty name" > @@ -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"); "Fail to attach port with empty name"