From patchwork Mon Jun 6 20:40:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 69452 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp1659638qgf; Mon, 6 Jun 2016 13:40:40 -0700 (PDT) X-Received: by 10.140.248.2 with SMTP id t2mr4179105qhc.7.1465245640193; Mon, 06 Jun 2016 13:40:40 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id f94si13151061qtb.114.2016.06.06.13.40.39; Mon, 06 Jun 2016 13:40:40 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 9CEEA68018; Mon, 6 Jun 2016 20:40:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id DE19263A39; Mon, 6 Jun 2016 20:40:35 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id C2E8F65079; Mon, 6 Jun 2016 20:40:34 +0000 (UTC) Received: from mail-oi0-f54.google.com (mail-oi0-f54.google.com [209.85.218.54]) by lists.linaro.org (Postfix) with ESMTPS id EE09E635C3 for ; Mon, 6 Jun 2016 20:40:33 +0000 (UTC) Received: by mail-oi0-f54.google.com with SMTP id s139so6299073oie.2 for ; Mon, 06 Jun 2016 13:40:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=8pJ5J+SXNoCapUUvnIaDJTIuYSrWwwUOYS1UV2wiVHQ=; b=FqGiFLPpvxMpgx3vXhLOldP5L58U1LSM01bK7iN+9vmUd1Z4PCfPop0rT6pI+lAuzL wrx3mEzdSr5O0NwkJJKBZttjIel18QEr3gu/+PlzbUPJihTMEjnnGSLqPN8S1tYrWZig HJXjB2DS24+P5Tj1n3lypGlUjUYMko6jtEjojBxHnoLa2Zznzs/MuNpZ4Cjmn8bsEUUt FfinCbzwlbJrmX986NL8HwISk4OU5a2cNIX7E1zP3EVpUcXdHFsX2nYeyFGv5mrlDITj csVNLXzmECcNnODUzuRO/50CRT/pGl1c9ewR/4GslVzMvmqGDLoGlPqS5J1cBOJdaZKZ tEQA== X-Gm-Message-State: ALyK8tKgG2R+VMoGDt9MJxbTlQ7XBGyeqMcGqzL4MWqVSQ41AZiMeT0wUpWQptmy08146NT4j/k= X-Received: by 10.202.72.9 with SMTP id v9mr10133896oia.199.1465245633467; Mon, 06 Jun 2016 13:40:33 -0700 (PDT) Received: from localhost.localdomain (cpe-66-68-129-43.austin.res.rr.com. [66.68.129.43]) by smtp.gmail.com with ESMTPSA id 3sm11240954ott.0.2016.06.06.13.40.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Jun 2016 13:40:32 -0700 (PDT) From: Bill Fischofer To: spinney@mellanox.com, lng-odp@lists.linaro.org Date: Mon, 6 Jun 2016 15:40:30 -0500 Message-Id: <1465245630-31425-1-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.7.4 X-Topics: patch Subject: [lng-odp] [PATCH] validation: tm: avoid resouce/memory leaks in corner cases X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" 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 --- 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..208671b 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) + destroy_tm_queue + (queue_desc->tm_queues[--priority]); + free(queue_desc); + free(node_desc); return NULL; } }