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 F314EA0471 for ; Fri, 21 Jun 2019 17:57:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 17CB11D558; Fri, 21 Jun 2019 17:57:17 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 31FB71D518; Fri, 21 Jun 2019 17:57:15 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Jun 2019 08:57:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,400,1557212400"; d="scan'208";a="183441162" Received: from silpixa00399126.ir.intel.com (HELO silpixa00399126.ger.corp.intel.com) ([10.237.223.2]) by fmsmga004.fm.intel.com with ESMTP; 21 Jun 2019 08:57:12 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , shreyansh.jain@nxp.com, stable@dpdk.org Date: Fri, 21 Jun 2019 16:56:56 +0100 Message-Id: <20190621155659.29297-2-bruce.richardson@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190621155659.29297-1-bruce.richardson@intel.com> References: <20190619170802.7691-1-bruce.richardson@intel.com> <20190621155659.29297-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 1/4] 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" Rawdev unit test for setting and getting parameters is failing because of a pointer value being dereferenced after the memory it pointed to is freed. 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