From patchwork Mon Jun 13 22:32:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 69956 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp1762346qgf; Mon, 13 Jun 2016 15:33:11 -0700 (PDT) X-Received: by 10.140.109.10 with SMTP id k10mr16355170qgf.89.1465857191025; Mon, 13 Jun 2016 15:33:11 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id j5si12424947qka.202.2016.06.13.15.33.10; Mon, 13 Jun 2016 15:33:11 -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 D2042685BF; Mon, 13 Jun 2016 22:33:09 +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_H2, 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 001CD68571; Mon, 13 Jun 2016 22:33:05 +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 870F3685B0; Mon, 13 Jun 2016 22:33:03 +0000 (UTC) Received: from mail-oi0-f44.google.com (mail-oi0-f44.google.com [209.85.218.44]) by lists.linaro.org (Postfix) with ESMTPS id A852068562 for ; Mon, 13 Jun 2016 22:33:02 +0000 (UTC) Received: by mail-oi0-f44.google.com with SMTP id d132so126472507oig.1 for ; Mon, 13 Jun 2016 15:33:02 -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=1nqjdQdRDsFKf7Ofa5UJpW7AUXjPZw3KYiz21WRRURI=; b=ONqHh8B4fBTUyJ53TzB5BWp8QqNR+2ad1NUR16nCFCTxGuubRzk8ynNAjjat8/Tkaf aA2GcMlt4XZy7HtlNDQQ0P33G4EvTd+iVNIvkbkabsi+tnWviYWe3L188xmSiHikAVuQ CaKdsno4g1CD2qrZWD9C7L9Sdqi+BmhpRP2DHSNpbKOTg1ucTAnRGd8OHhLhUGkmD/Od ykpzg36k7wl/fV+let88Ilk5tdVfAGW9CiE5VcH1i4IhSDdPyVTRez8FBuDA6Y8by6Cy qEWOPReN80RGrXsvidtwdy8VuN2Ng9fm6hcjNcY8K2hfN42gdfY3mHXvkzJn6oehSH/S L+Hg== X-Gm-Message-State: ALyK8tInQq+GhxbFyCAG2bH3FjlEm3/q5ASuiz2UJiVeGW+2ONsCactX77QCGqZJyX+rXNoWDbE= X-Received: by 10.202.104.72 with SMTP id d69mr7164004oic.99.1465857182150; Mon, 13 Jun 2016 15:33:02 -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 p8sm1766918oia.9.2016.06.13.15.32.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Jun 2016 15:32:59 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Mon, 13 Jun 2016 17:32:56 -0500 Message-Id: <1465857176-22202-1-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.7.4 X-Topics: patch Subject: [lng-odp] [PATCHv2] 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 --- 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; } }