From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shreyansh Jain Subject: [PATCH] raw/skeleton_rawdev: fix memory leak on test failure Date: Wed, 24 Oct 2018 05:33:41 +0000 Message-ID: <20181024053302.22937-1-shreyansh.jain@nxp.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: "thomas@monjalon.net" , Shreyansh Jain To: "dev@dpdk.org" Return-path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50041.outbound.protection.outlook.com [40.107.5.41]) by dpdk.org (Postfix) with ESMTP id C0AA04C9F for ; Wed, 24 Oct 2018 07:33:42 +0200 (CEST) Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" In skeleton_rawdev unit tests, a malloc'd memory was leaking in case the next sequential test fails. This fix moves the free of the malloc'd memory above the failing test. Coverity issue: 260402 Fixes: 55ca1b0f2151 ("raw/skeleton: add test cases") Cc: shreyansh.jain@nxp.com Signed-off-by: Shreyansh Jain --- drivers/raw/skeleton_rawdev/skeleton_rawdev_test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/raw/skeleton_rawdev/skeleton_rawdev_test.c b/drivers/r= aw/skeleton_rawdev/skeleton_rawdev_test.c index 3405b8984..359c9e296 100644 --- a/drivers/raw/skeleton_rawdev/skeleton_rawdev_test.c +++ b/drivers/raw/skeleton_rawdev/skeleton_rawdev_test.c @@ -294,13 +294,14 @@ test_rawdev_attr_set_get(void) "Attribute (Test1) not set correctly (%" PRIu64 ")", ret_value); =20 + free(dummy_value); + ret_value =3D 0; ret =3D rte_rawdev_get_attr(TEST_DEV_ID, "Test2", &ret_value); RTE_TEST_ASSERT_EQUAL(*((int *)(uintptr_t)ret_value), 200, "Attribute (Test2) not set correctly (%" PRIu64 ")", ret_value); =20 - free(dummy_value); return TEST_SUCCESS; } =20 --=20 2.17.1