From patchwork Mon Jul 15 15:39:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Carrillo, Erik G" X-Patchwork-Id: 56461 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DF6414CE4; Mon, 15 Jul 2019 17:39:24 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 933702BA8; Mon, 15 Jul 2019 17:39:21 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Jul 2019 08:39:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,493,1557212400"; d="scan'208";a="161116891" Received: from wcpqa1.an.intel.com ([10.123.72.207]) by orsmga008.jf.intel.com with ESMTP; 15 Jul 2019 08:39:19 -0700 From: Erik Gabriel Carrillo To: thomas@monjalon.net Cc: dev@dpdk.org, stable@dpdk.org Date: Mon, 15 Jul 2019 10:39:31 -0500 Message-Id: <1563205172-352-2-git-send-email-erik.g.carrillo@intel.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1563205172-352-1-git-send-email-erik.g.carrillo@intel.com> References: <1563205172-352-1-git-send-email-erik.g.carrillo@intel.com> Subject: [dpdk-dev] [PATCH 1/2] timer: fix null pointer dereference X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" If the timer subsystem is not initialized before rte_timer_manage (for example) is invoked, a pointer to a shared hugepage memory region will still be null and dereferenced when it is checked for validity; handle this case. Fixes: c0749f7096c7 ("timer: allow management in shared memory") Cc: stable@dpdk.org Signed-off-by: Erik Gabriel Carrillo --- lib/librte_timer/rte_timer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c index 71dffd2..bdcf05d 100644 --- a/lib/librte_timer/rte_timer.c +++ b/lib/librte_timer/rte_timer.c @@ -85,7 +85,8 @@ static struct rte_timer_data default_timer_data; static inline int timer_data_valid(uint32_t id) { - return !!(rte_timer_data_arr[id].internal_flags & FL_ALLOCATED); + return rte_timer_data_arr && + (rte_timer_data_arr[id].internal_flags & FL_ALLOCATED); } /* validate ID and retrieve timer data pointer, or return error value */ From patchwork Mon Jul 15 15:39:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Carrillo, Erik G" X-Patchwork-Id: 56462 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8FFD51B96E; Mon, 15 Jul 2019 17:39:27 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 10EF82C18; Mon, 15 Jul 2019 17:39:21 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Jul 2019 08:39:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,493,1557212400"; d="scan'208";a="161116902" Received: from wcpqa1.an.intel.com ([10.123.72.207]) by orsmga008.jf.intel.com with ESMTP; 15 Jul 2019 08:39:20 -0700 From: Erik Gabriel Carrillo To: thomas@monjalon.net Cc: dev@dpdk.org, stable@dpdk.org, ian.betts@intel.com Date: Mon, 15 Jul 2019 10:39:32 -0500 Message-Id: <1563205172-352-3-git-send-email-erik.g.carrillo@intel.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1563205172-352-1-git-send-email-erik.g.carrillo@intel.com> References: <1563205172-352-1-git-send-email-erik.g.carrillo@intel.com> Subject: [dpdk-dev] [PATCH 2/2] examples/performance-thread: init timer subsystem X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The timer subsystem should be initialized in the l3fwd-thread app before the L-thread subsystem can be used. Fixes: d48415e1fee3 ("examples/performance-thread: add l3fwd-thread app") Cc: stable@dpdk.org Cc: ian.betts@intel.com Signed-off-by: Erik Gabriel Carrillo --- examples/performance-thread/l3fwd-thread/main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/performance-thread/l3fwd-thread/main.c b/examples/performance-thread/l3fwd-thread/main.c index dd46895..c4065e8 100644 --- a/examples/performance-thread/l3fwd-thread/main.c +++ b/examples/performance-thread/l3fwd-thread/main.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -3497,6 +3498,10 @@ main(int argc, char **argv) argc -= ret; argv += ret; + ret = rte_timer_subsystem_init(); + if (ret < 0) + rte_exit(EXIT_FAILURE, "Failed to initialize timer subystem\n"); + /* pre-init dst MACs for all ports to 02:00:00:00:00:xx */ for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) { dest_eth_addr[portid] = RTE_ETHER_LOCAL_ADMIN_ADDR +