From patchwork Sat Apr 2 13:52:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 64932 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp338528lbc; Sat, 2 Apr 2016 06:53:00 -0700 (PDT) X-Received: by 10.140.109.100 with SMTP id k91mr31290276qgf.54.1459605180126; Sat, 02 Apr 2016 06:53:00 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id f98si2176206qge.25.2016.04.02.06.52.59; Sat, 02 Apr 2016 06:53:00 -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 322DB617AC; Sat, 2 Apr 2016 13:52:59 +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 5DB6B61795; Sat, 2 Apr 2016 13:52:55 +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 3522261610; Sat, 2 Apr 2016 13:52:54 +0000 (UTC) Received: from mail-oi0-f43.google.com (mail-oi0-f43.google.com [209.85.218.43]) by lists.linaro.org (Postfix) with ESMTPS id 5FC86615BB for ; Sat, 2 Apr 2016 13:52:53 +0000 (UTC) Received: by mail-oi0-f43.google.com with SMTP id p188so110009988oih.2 for ; Sat, 02 Apr 2016 06:52:53 -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=Gw6Vr+kvc1KVLxsR0KAYbx3tGxNGm2LDTou76M/iaws=; b=Dx8pODGV2S0qgbu7gXxukFt7OCth5mcrFaxgmVWfjVWexnGByjiF3R+DgECUSfVFM1 A4vRr/+4YXwWc0LddkRdIVs26x+/EJKlKn5SY8a3f+mmRFK60bZ5nssSpAMbLBTHT4J3 xd6dxbffJBb9mIPfVnX6qY+yH0jPbcKr+T0BUdTS1+RoKbuC61N3eqMiv++B1Ao5SC9q K5lrqDvNv4bc2i5CgT57oLafdSLhX+b6/Rt65CrE9cuAj1Kc8nyDevrXvY9IjeAneNki 9J8oiMKEViQvAXxnRfwOy0XB7l2qDlMkZDH/8FTQoQarRI/xKAb7/HxY0qcXxi/kPFp9 lDKw== X-Gm-Message-State: AD7BkJLjzwJ6yUztAaJAc/qnP49klh5tNQuzKUM/mHeMbBThEN9l+M539MDfiskL72EmR6VzN10= X-Received: by 10.157.33.73 with SMTP id l9mr6429297otd.9.1459605172951; Sat, 02 Apr 2016 06:52:52 -0700 (PDT) Received: from Ubuntu15.localdomain (cpe-66-68-129-43.austin.res.rr.com. [66.68.129.43]) by smtp.gmail.com with ESMTPSA id k2sm5560049oey.3.2016.04.02.06.52.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 02 Apr 2016 06:52:52 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Sat, 2 Apr 2016 08:52:49 -0500 Message-Id: <1459605169-1563-1-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.5.0 X-Topics: patch Subject: [lng-odp] [PATCHv2] linux-generic: pktio: handle transient output queue nonempty conditions 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" Out queues should be empty. Add an assert to verify this to ensure that memory is not leaked as part of destroy_out_queues(). This addresses bug https://bugs.linaro.org/show_bug.cgi?id=2089 Signed-off-by: Bill Fischofer --- Changes for v2: Switch to ODP_ASSERT() rather than risk looping in the unlikely event that an output queue is non-empty. This prevents the memory leak while catching the bug condition that would have resulted in the leak without this check. platform/linux-generic/odp_packet_io.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 9192be2..7b1b137 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -296,11 +296,12 @@ static void destroy_in_queues(pktio_entry_t *entry, int num) static void destroy_out_queues(pktio_entry_t *entry, int num) { - int i; + int i, rc; for (i = 0; i < num; i++) { if (entry->s.out_queue[i].queue != ODP_QUEUE_INVALID) { - odp_queue_destroy(entry->s.out_queue[i].queue); + rc = odp_queue_destroy(entry->s.out_queue[i].queue); + ODP_ASSERT(rc == 0); entry->s.out_queue[i].queue = ODP_QUEUE_INVALID; } }