From patchwork Tue Oct 13 17:05:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 54861 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by patches.linaro.org (Postfix) with ESMTPS id 0699020490 for ; Tue, 13 Oct 2015 17:06:13 +0000 (UTC) Received: by wicid10 with SMTP id id10sf13701049wic.2 for ; Tue, 13 Oct 2015 10:06:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=nfGaAZON7N30zIMcFwpQlYSf2mhyAnTi58elmvvMI4g=; b=i90aiXYLWgA/p9V0/I/fiMh8ayysNUyWE/FxgD4vxUgsP06uoxr0iKPv1Rz/XFQZf8 s3X4+bS9FDIuj0SaZt0ZHy6YKLLXFU8nnM03blHARcAiBTncyWta0DIp5azmt7QbcfhC kC5vYaUoHI9g4F9N2ma2SguO6yNN0BqIvOeGL6ZJZ0XDtLI6v8NdjIFQwCQDIjf73Ci9 NTXD/Q72hoJbc9qw8gZRsS+kbBnLctZccxH/XcdV+5pNVogUjvuAH8q4eGswRLa6SbHD n5rshtrTjI/hYJ+PovilIh/1jRI+gz5jeqMiOLgKxI/AhGQOF4ciixpR4VaoeyfiVEJB iVTg== X-Gm-Message-State: ALoCoQnvryER7AdQzqZIxOK64Yme5IBNwwv5xMHlygNM5X7uuOcGXRjWsnOsiYUBOSry9ZDqYct3 X-Received: by 10.112.55.69 with SMTP id q5mr7193730lbp.24.1444755972239; Tue, 13 Oct 2015 10:06:12 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.15.147 with SMTP id 19ls218339lfp.5.gmail; Tue, 13 Oct 2015 10:06:12 -0700 (PDT) X-Received: by 10.25.209.80 with SMTP id i77mr10213781lfg.92.1444755972095; Tue, 13 Oct 2015 10:06:12 -0700 (PDT) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com. [209.85.217.172]) by mx.google.com with ESMTPS id sm5si2731017lbb.88.2015.10.13.10.06.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Oct 2015 10:06:11 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by lbbck17 with SMTP id ck17so28278570lbb.1 for ; Tue, 13 Oct 2015 10:06:11 -0700 (PDT) X-Received: by 10.112.17.34 with SMTP id l2mr15326410lbd.117.1444755971640; Tue, 13 Oct 2015 10:06:11 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp2246621lbq; Tue, 13 Oct 2015 10:06:10 -0700 (PDT) X-Received: by 10.50.79.164 with SMTP id k4mr19651000igx.16.1444755970241; Tue, 13 Oct 2015 10:06:10 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id qm2si3807270igb.45.2015.10.13.10.06.09; Tue, 13 Oct 2015 10:06:10 -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; Received: by lists.linaro.org (Postfix, from userid 109) id 8442961BC3; Tue, 13 Oct 2015 17:06: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_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 6CE4F61B4C; Tue, 13 Oct 2015 17:06:03 +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 9EEEC61B7F; Tue, 13 Oct 2015 17:05:59 +0000 (UTC) Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com [209.85.212.179]) by lists.linaro.org (Postfix) with ESMTPS id ADEFE61B3F for ; Tue, 13 Oct 2015 17:05:58 +0000 (UTC) Received: by wicge5 with SMTP id ge5so67488915wic.0 for ; Tue, 13 Oct 2015 10:05:58 -0700 (PDT) X-Received: by 10.180.88.37 with SMTP id bd5mr23797775wib.82.1444755957726; Tue, 13 Oct 2015 10:05:57 -0700 (PDT) Received: from e106441.emea.arm.com ([2001:41d0:a:3cb4::abcd]) by smtp.gmail.com with ESMTPSA id p2sm4784346wjb.21.2015.10.13.10.05.56 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Oct 2015 10:05:56 -0700 (PDT) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Tue, 13 Oct 2015 18:05:47 +0100 Message-Id: <1444755947-13418-1-git-send-email-stuart.haslam@linaro.org> X-Mailer: git-send-email 2.1.1 X-Topics: patch Subject: [lng-odp] [PATCH] validation: pktio: don't call APIs with an invalid pktio handle X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: 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" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: stuart.haslam@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 If one of the pktio interfaces used by the test unexpectedly fails to open an invalid pktio handle is passed on to further API calls resulting in undefined behaviour. Reported-by: Anders Roxell Signed-off-by: Stuart Haslam Reviewed-by: Bill Fischofer --- This causes a seg fault when testing the linux-generic implementation, it can be easily reproduced with; ODP_PKTIO_IF0=blah ODP_PKTIO_IF1=foo ./test/validation/pktio/pktio_main test/validation/pktio/pktio.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c index 118fe89..d4b447a 100644 --- a/test/validation/pktio/pktio.c +++ b/test/validation/pktio/pktio.c @@ -520,7 +520,9 @@ void pktio_test_mtu(void) { int ret; int mtu; + odp_pktio_t pktio = create_pktio(iface_name[0], ODP_QUEUE_TYPE_SCHED, 0); + CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID); mtu = odp_pktio_mtu(pktio); CU_ASSERT(mtu > 0); @@ -534,7 +536,9 @@ void pktio_test_mtu(void) void pktio_test_promisc(void) { int ret; + odp_pktio_t pktio = create_pktio(iface_name[0], ODP_QUEUE_TYPE_SCHED, 0); + CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID); ret = odp_pktio_promisc_mode_set(pktio, 1); CU_ASSERT(0 == ret); @@ -562,6 +566,7 @@ void pktio_test_mac(void) odp_pktio_t pktio; pktio = create_pktio(iface_name[0], ODP_QUEUE_TYPE_SCHED, 0); + CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID); printf("testing mac for %s\n", iface_name[0]); @@ -589,7 +594,7 @@ void pktio_test_inq_remdef(void) int i; pktio = create_pktio(iface_name[0], ODP_QUEUE_TYPE_SCHED, 0); - CU_ASSERT(pktio != ODP_PKTIO_INVALID); + CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID); CU_ASSERT(create_inq(pktio, ODP_QUEUE_TYPE_POLL) == 0); inq = odp_pktio_inq_getdef(pktio); CU_ASSERT(inq != ODP_QUEUE_INVALID); @@ -617,7 +622,7 @@ void pktio_test_open(void) /* test the sequence open->close->open->close() */ for (i = 0; i < 2; ++i) { pktio = create_pktio(iface_name[0], ODP_QUEUE_TYPE_SCHED, 0); - CU_ASSERT(pktio != ODP_PKTIO_INVALID); + CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID); CU_ASSERT(odp_pktio_close(pktio) == 0); } @@ -656,7 +661,7 @@ void pktio_test_inq(void) odp_pktio_t pktio; pktio = create_pktio(iface_name[0], ODP_QUEUE_TYPE_SCHED, 0); - CU_ASSERT(pktio != ODP_PKTIO_INVALID); + CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID); CU_ASSERT(create_inq(pktio, ODP_QUEUE_TYPE_POLL) == 0); CU_ASSERT(destroy_inq(pktio) == 0); @@ -675,7 +680,7 @@ static void pktio_test_start_stop(void) for (i = 0; i < num_ifaces; i++) { pktio[i] = create_pktio(iface_name[i], ODP_QUEUE_TYPE_SCHED, 0); - CU_ASSERT(pktio[i] != ODP_PKTIO_INVALID); + CU_ASSERT_FATAL(pktio[i] != ODP_PKTIO_INVALID); create_inq(pktio[i], ODP_QUEUE_TYPE_SCHED); }