Message ID | 1465857176-22202-1-git-send-email-bill.fischofer@linaro.org |
---|---|
State | Accepted |
Commit | 72b2a7212b6afb2d011e537202611e5566584aea |
Headers | show |
Merged, Maxim. On 06/14/16 01:32, Bill Fischofer wrote: > Resolve Bug https://bugs.linaro.org/show_bug.cgi?id=2306 by cleaning up > TM queues and nodes in error paths. > > Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org> > --- > v2: Add (void) to dstroy_tm_queue() call as suggested by Maxim > > test/validation/traffic_mngr/traffic_mngr.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/test/validation/traffic_mngr/traffic_mngr.c b/test/validation/traffic_mngr/traffic_mngr.c > index a0cde43..ce9d038 100644 > --- a/test/validation/traffic_mngr/traffic_mngr.c > +++ b/test/validation/traffic_mngr/traffic_mngr.c > @@ -1325,12 +1325,19 @@ static int create_tm_queue(odp_tm_t odp_tm, > rc = odp_tm_queue_connect(tm_queue, tm_node); > if (rc != 0) { > LOG_ERR("odp_tm_queue_connect() failed\n"); > + odp_tm_queue_destroy(tm_queue); > return -1; > } > > return 0; > } > > +static int destroy_tm_queue(odp_tm_queue_t tm_queue) > +{ > + odp_tm_queue_disconnect(tm_queue); > + return odp_tm_queue_destroy(tm_queue); > +} > + > static tm_node_desc_t *create_tm_node(odp_tm_t odp_tm, > uint32_t level, > uint32_t num_levels, > @@ -1392,6 +1399,7 @@ static tm_node_desc_t *create_tm_node(odp_tm_t odp_tm, > if (rc != 0) { > LOG_ERR("odp_tm_node_connect() failed @ level=%u\n", > level); > + odp_tm_node_destroy(tm_node); > return NULL; > } > > @@ -1425,6 +1433,11 @@ static tm_node_desc_t *create_tm_node(odp_tm_t odp_tm, > if (rc != 0) { > LOG_ERR("create_tm_queue() failed @ level=%u\n", > level); > + while (priority > 0) > + (void)destroy_tm_queue > + (queue_desc->tm_queues[--priority]); > + free(queue_desc); > + free(node_desc); > return NULL; > } > }
diff --git a/test/validation/traffic_mngr/traffic_mngr.c b/test/validation/traffic_mngr/traffic_mngr.c index a0cde43..ce9d038 100644 --- a/test/validation/traffic_mngr/traffic_mngr.c +++ b/test/validation/traffic_mngr/traffic_mngr.c @@ -1325,12 +1325,19 @@ static int create_tm_queue(odp_tm_t odp_tm, rc = odp_tm_queue_connect(tm_queue, tm_node); if (rc != 0) { LOG_ERR("odp_tm_queue_connect() failed\n"); + odp_tm_queue_destroy(tm_queue); return -1; } return 0; } +static int destroy_tm_queue(odp_tm_queue_t tm_queue) +{ + odp_tm_queue_disconnect(tm_queue); + return odp_tm_queue_destroy(tm_queue); +} + static tm_node_desc_t *create_tm_node(odp_tm_t odp_tm, uint32_t level, uint32_t num_levels, @@ -1392,6 +1399,7 @@ static tm_node_desc_t *create_tm_node(odp_tm_t odp_tm, if (rc != 0) { LOG_ERR("odp_tm_node_connect() failed @ level=%u\n", level); + odp_tm_node_destroy(tm_node); return NULL; } @@ -1425,6 +1433,11 @@ static tm_node_desc_t *create_tm_node(odp_tm_t odp_tm, if (rc != 0) { LOG_ERR("create_tm_queue() failed @ level=%u\n", level); + while (priority > 0) + (void)destroy_tm_queue + (queue_desc->tm_queues[--priority]); + free(queue_desc); + free(node_desc); return NULL; } }
Resolve Bug https://bugs.linaro.org/show_bug.cgi?id=2306 by cleaning up TM queues and nodes in error paths. Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org> --- v2: Add (void) to dstroy_tm_queue() call as suggested by Maxim test/validation/traffic_mngr/traffic_mngr.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)