From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 271101B40F; Wed, 24 Apr 2019 16:35:17 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Apr 2019 07:35:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,390,1549958400"; d="scan'208";a="167505381" Received: from txasoft-yocto.an.intel.com ([10.123.72.192]) by fmsmga001.fm.intel.com with ESMTP; 24 Apr 2019 07:35:16 -0700 From: Erik Gabriel Carrillo To: john.mcnamara@intel.com Cc: marko.kovacevic@intel.com, dev@dpdk.org, stable@dpdk.org Date: Wed, 24 Apr 2019 09:33:50 -0500 Message-Id: <1556116430-22593-1-git-send-email-erik.g.carrillo@intel.com> X-Mailer: git-send-email 1.7.10 Subject: [dpdk-dev] [PATCH] timer: fix pointer to local outside scope 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: , X-List-Received-Date: Wed, 24 Apr 2019 14:35:18 -0000 A null array is allowed to be passed as one of the parameters to rte_timer_alt_manage() as a convenience. When that happened, an anonymous array was created using compound literal syntax, and Coverity detected that the object was out of scope in later uses of it. Create an object in the proper scope instead. Coverity issue: 337919 Fixes: c0749f7096c7 ("timer: allow management in shared memory") Cc: stable@dpdk.org Signed-off-by: Erik Gabriel Carrillo --- lib/librte_timer/rte_timer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c index eb46009..d443b8c 100644 --- a/lib/librte_timer/rte_timer.c +++ b/lib/librte_timer/rte_timer.c @@ -826,6 +826,7 @@ rte_timer_alt_manage(uint32_t timer_data_id, int nb_poll_lcores, rte_timer_alt_manage_cb_t f) { + unsigned int default_poll_lcores[] = {rte_lcore_id()}; union rte_timer_status status; struct rte_timer *tim, *next_tim, **pprev; struct rte_timer *run_first_tims[RTE_MAX_LCORE]; @@ -847,8 +848,8 @@ rte_timer_alt_manage(uint32_t timer_data_id, __TIMER_STAT_ADD(data->priv_timer, manage, 1); if (poll_lcores == NULL) { - poll_lcores = (unsigned int []){rte_lcore_id()}; - nb_poll_lcores = 1; + poll_lcores = default_poll_lcores; + nb_poll_lcores = RTE_DIM(default_poll_lcores); } for (i = 0; i < nb_poll_lcores; i++) { -- 2.6.4 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 450B1A05D3 for ; Wed, 24 Apr 2019 16:35:20 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2B3B41B4D5; Wed, 24 Apr 2019 16:35:19 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 271101B40F; Wed, 24 Apr 2019 16:35:17 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Apr 2019 07:35:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,390,1549958400"; d="scan'208";a="167505381" Received: from txasoft-yocto.an.intel.com ([10.123.72.192]) by fmsmga001.fm.intel.com with ESMTP; 24 Apr 2019 07:35:16 -0700 From: Erik Gabriel Carrillo To: john.mcnamara@intel.com Cc: marko.kovacevic@intel.com, dev@dpdk.org, stable@dpdk.org Date: Wed, 24 Apr 2019 09:33:50 -0500 Message-Id: <1556116430-22593-1-git-send-email-erik.g.carrillo@intel.com> X-Mailer: git-send-email 1.7.10 Subject: [dpdk-dev] [PATCH] timer: fix pointer to local outside scope 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" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190424143350.zwzbxxJ9mZ95UuA7xWTP-CP5y6iz7yOT_c7oILCjrxY@z> A null array is allowed to be passed as one of the parameters to rte_timer_alt_manage() as a convenience. When that happened, an anonymous array was created using compound literal syntax, and Coverity detected that the object was out of scope in later uses of it. Create an object in the proper scope instead. Coverity issue: 337919 Fixes: c0749f7096c7 ("timer: allow management in shared memory") Cc: stable@dpdk.org Signed-off-by: Erik Gabriel Carrillo --- lib/librte_timer/rte_timer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c index eb46009..d443b8c 100644 --- a/lib/librte_timer/rte_timer.c +++ b/lib/librte_timer/rte_timer.c @@ -826,6 +826,7 @@ rte_timer_alt_manage(uint32_t timer_data_id, int nb_poll_lcores, rte_timer_alt_manage_cb_t f) { + unsigned int default_poll_lcores[] = {rte_lcore_id()}; union rte_timer_status status; struct rte_timer *tim, *next_tim, **pprev; struct rte_timer *run_first_tims[RTE_MAX_LCORE]; @@ -847,8 +848,8 @@ rte_timer_alt_manage(uint32_t timer_data_id, __TIMER_STAT_ADD(data->priv_timer, manage, 1); if (poll_lcores == NULL) { - poll_lcores = (unsigned int []){rte_lcore_id()}; - nb_poll_lcores = 1; + poll_lcores = default_poll_lcores; + nb_poll_lcores = RTE_DIM(default_poll_lcores); } for (i = 0; i < nb_poll_lcores; i++) { -- 2.6.4