From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 09182A0679 for ; Wed, 3 Apr 2019 18:08:04 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A55751B49A; Wed, 3 Apr 2019 18:08:03 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 33BEF1B45B; Wed, 3 Apr 2019 18:07:59 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Apr 2019 09:07:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,305,1549958400"; d="scan'208";a="139687837" Received: from awal-z170x.ir.intel.com ([163.33.210.59]) by orsmga003.jf.intel.com with ESMTP; 03 Apr 2019 09:07:56 -0700 From: Mohammad Abdul Awal To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@intel.com, arybchenko@solarflare.com, Mohammad Abdul Awal , stable@dpdk.org Date: Wed, 3 Apr 2019 17:07:26 +0100 Message-Id: <20190403160726.1231-1-mohammad.abdul.awal@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-stable] [PATCH 1/3] ethdev: fix null pointer checking X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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 --- 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