timer: fix pointer to local outside scope
Checks
Commit Message
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 <erik.g.carrillo@intel.com>
---
lib/librte_timer/rte_timer.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Comments
24/04/2019 16:33, Erik Gabriel Carrillo:
> 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
No need to Cc stable for a commit introduced in this release.
> Signed-off-by: Erik Gabriel Carrillo <erik.g.carrillo@intel.com>
Applied, thanks
@@ -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++) {