From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 2D00CA0471 for ; Wed, 19 Jun 2019 19:08:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 975C41D0C9; Wed, 19 Jun 2019 19:08:16 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 1DF471D0C0; Wed, 19 Jun 2019 19:08:13 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Jun 2019 10:08:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,393,1557212400"; d="scan'208";a="165076985" Received: from silpixa00399126.ir.intel.com (HELO silpixa00399126.ger.corp.intel.com) ([10.237.223.2]) by orsmga006.jf.intel.com with ESMTP; 19 Jun 2019 10:08:12 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , shreyansh.jain@nxp.com, stable@dpdk.org Date: Wed, 19 Jun 2019 18:08:01 +0100 Message-Id: <20190619170802.7691-2-bruce.richardson@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190619170802.7691-1-bruce.richardson@intel.com> References: <20190619170802.7691-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 1/2] raw/skeleton: fix failing test case X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The freeing of the malloced memory is difficult when using asserts to cause early abort of the test cases, since that can leak memory. The original placement of the free call caused a memory leak if the test finished early, while a fix for that leak caused the test to fail at times due to the memory variable being referenced after free. For a case like this, using stack rather than heap memory is just easier and avoids all issues. Fixes: 55ca1b0f2151 ("raw/skeleton: add test cases") Fixes: 88d0e47880ec ("raw/skeleton: fix memory leak on test failure") Cc: shreyansh.jain@nxp.com Cc: stable@dpdk.org Signed-off-by: Bruce Richardson --- drivers/raw/skeleton_rawdev/skeleton_rawdev_test.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/raw/skeleton_rawdev/skeleton_rawdev_test.c b/drivers/raw/skeleton_rawdev/skeleton_rawdev_test.c index 359c9e296..a0961c77b 100644 --- a/drivers/raw/skeleton_rawdev/skeleton_rawdev_test.c +++ b/drivers/raw/skeleton_rawdev/skeleton_rawdev_test.c @@ -274,17 +274,14 @@ static int test_rawdev_attr_set_get(void) { int ret; - int *dummy_value; + int dummy_value_store; + int *dummy_value = &dummy_value_store; uint64_t ret_value; /* Set an attribute and fetch it */ ret = rte_rawdev_set_attr(TEST_DEV_ID, "Test1", 100); RTE_TEST_ASSERT(!ret, "Unable to set an attribute (Test1)"); - dummy_value = malloc(sizeof(int)); - if (!dummy_value) - RTE_TEST_ASSERT(1, "Unable to allocate memory (dummy_value)"); - *dummy_value = 200; ret = rte_rawdev_set_attr(TEST_DEV_ID, "Test2", (uintptr_t)dummy_value); @@ -294,7 +291,6 @@ test_rawdev_attr_set_get(void) "Attribute (Test1) not set correctly (%" PRIu64 ")", ret_value); - free(dummy_value); ret_value = 0; ret = rte_rawdev_get_attr(TEST_DEV_ID, "Test2", &ret_value); -- 2.21.0