From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0056.outbound.protection.outlook.com [104.47.0.56]) by dpdk.org (Postfix) with ESMTP id 62C661B6DD; Wed, 9 May 2018 17:11:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=5BsIyJL7e1E8hv/eJdSudTEJ2SBqpaxYnEOohFD4oFQ=; b=j2D7MadX6zCx6hMAJ+BRaS5d+9FjScwzQjw2yIeKhLnrI6GhJZ9XFYgUIe4o4rgOcH6zSAsfYVk8tUstBQMN2asBezhGC3IVl7mt4IJ2pKiLMO+iFkAtpUJBgoApXQL6RSvcizb0gQZI8UGIgRGY80wBdH7Up4XuDr007si9NrU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=shreyansh.jain@nxp.com; Received: from Tophie.ap.freescale.net (14.142.187.166) by AM5PR0402MB2771.eurprd04.prod.outlook.com (2603:10a6:203:98::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.755.16; Wed, 9 May 2018 15:11:23 +0000 From: Shreyansh Jain To: thomas@monjalon.net Cc: dev@dpdk.org, Shreyansh Jain , stable@dpdk.org Date: Wed, 9 May 2018 20:57:51 +0530 Message-Id: <20180509152752.30421-1-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.17.0 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.142.187.166] X-ClientProxiedBy: BM1PR0101CA0070.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:19::32) To AM5PR0402MB2771.eurprd04.prod.outlook.com (2603:10a6:203:98::13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(5600026)(48565401081)(2017052603328)(7153060)(7193020); SRVR:AM5PR0402MB2771; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0402MB2771; 3:u3XwCNK/8KKy00h5nhodG1Ok0anw4n/XEc/zaH7R9E6eLAD71vikpb7kjbEZdilQc5Ke4qqxnFNBOjqPZyJ8xEVP1r1bHCMzENH1+4lRSfTwq61yE0hQklBrURSHyNru/9+971SKqVhR1XdOn0oumOSA2R5FKOEWrvmDIE14q0Xe9fHImo6OBjRBenSrD+EjhxfjKQ2ii4VmsOu1FOvATzqRaGqQacoF5BGeooCLIPkMQ/7PExEuhzg7+hjlorJI; 25:nm4WbXIhMK+yYmbFM5+SI0nPpBoMHdSwSbZ7KPYJzAmIIh66mIJmwzi9glMeZakX5V+CnTESml+uMYJRWx/U3dTehXhTgsJtt/FGIziVaHnQVler5l0rLkoYLdzW/e7Rf9R+qCCQuOEZJxjS68VSj4C1XhmbrCRRW1VCVcROmL4mYupzDTjhb9jNympCfgg6gHeddVqUjNPvuWgQrFhYb9Yi+pWjH/syGzKK1NFu1nWY2bZi9epT22BXMoRGxKG0AEshHM0/Qn9Ct1USm7IesXn5HpeJ3Xpm3fi6Gc+NHXVCLGHOOsRHwN70WE6ag+98sIiasNoodiVRxFd34+K/7w==; 31:mC2XbpDEiFCkoSZnULhUVAk9K61IU5kIjvotsa0sa1fe7aiQOOOmMxFUiYZvdpBnUrRXpiFe4Us75dx7keBplpS7ltiLkdpEV9jCbyZS2JEFLGahixFnYMzRPOYZJc0hXdeG8Yd2a65oIBycG+zz0757rLnVFsrRXYCGCJ0CFN6iQhjBnRlQo4/E56ZsqenepbQiK0QCIMG1VWfrD4ip32D3sDfHswqWASyHXz96JAY= X-MS-TrafficTypeDiagnostic: AM5PR0402MB2771: X-Microsoft-Exchange-Diagnostics: 1; AM5PR0402MB2771; 20:XqmliRdpFhSAQxgQeLT6BBkfIxNZMAplk3h7UfSfZdQtSIV3H9AhiNuikYHco6DAwxKjbnS0kg1URnG0jrWWbZ0SFrVImUKt7kXr8kNFt2dx5GMzVZAbWaugnP20wh2D5uCbvF6VW0Zhi/xqMn8EDEfy1tZyqDaARckDErRiM0mG2IJ8rkw38tAe2yrEu5OPbSWP+Q/FPDbTwdFfx7Km5xM9yqCyDh5DFXe3pDXeEZepI6yHEVwABrCNuislfPIYJvlQ1BWvKqZchSXuo3eYpwN12OtUb7tgE9hSiPEIbi7hcuoNDJ+tJ5BwDTlzuhDx+wxqZNfNdzPyAnwFktKdbly7uGacvhxOB/cV+BcGZvIVbBwA9XoihsJ25KqUKxuBG+EHULUFBxA5uHYhmunFsJcv//ZTbO/ynJJ80aLu/vd506VRBvJZx4WrfOrd8vnx/SG8zQJpm7083PIF/CanJimhPbCfUm/cAdbBKPfh0Xm5Ay8PHgO/KZkMmqTba2Oj; 4:FlmRZmEXZ34LIQi9FwSUOnHL5c47eJoAWk4ZX2VnjTWTJpSpvf4vCLxwgyeORyop6p9R03eODMTI9mDSu6i/yRuxRQcr9oaQ8su5JCLzRXgAy1zoGOXNHksdaC9dKCPbp6GkAFRLtHZRDyTb+VJKJQEFoQV/EBWfEA6X7HJXbadUFyrlrlPoRH4aDRClyYhLDr9en4gVBMjfL7ovNil+SfdwXDLEjxUHaJsL0ywB0uSof5646pbh2HVZy31TrSPPC4ERuQszOHVi6Ru4uxA0MMqdpFy2Olr4zH4cG9+UMw1AbkSK3/VRAgMWVLaVmfHjGygGFOxnvvKZzrqFbHrkIjJNNO878FKa3aOpzJ6WfEI= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(275809806118684); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(3231254)(944501410)(52105095)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:AM5PR0402MB2771; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0402MB2771; X-Forefront-PRVS: 0667289FF8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(39860400002)(346002)(39380400002)(376002)(366004)(199004)(189003)(50226002)(48376002)(5660300001)(86362001)(44832011)(6506007)(5009440100003)(4326008)(1076002)(386003)(16526019)(55236004)(3846002)(8676002)(186003)(105586002)(2351001)(50466002)(26005)(81166006)(81156014)(2361001)(8936002)(6116002)(106356001)(7736002)(68736007)(2906002)(53936002)(6486002)(47776003)(478600001)(36756003)(25786009)(316002)(97736004)(51416003)(476003)(486006)(6916009)(52116002)(956004)(66066001)(305945005)(6512007)(16586007)(6666003)(2616005)(110426005); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0402MB2771; H:Tophie.ap.freescale.net; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:3; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM5PR0402MB2771; 23:XOTpDUMIKU/Ri0cLA+b3f6uy58Jf92HJlgSDkMK?= =?us-ascii?Q?9vsKxIx4k3uIB3JPKa0+EBBgdLd0MT2I6hr5eZtAnukdTWy6QGH7++JEW3pH?= =?us-ascii?Q?zwdpn4uNey2EDtn6etgBLNeQFOVTOF3wcSE9B7954tpW51MeADI5C4ww4a+p?= =?us-ascii?Q?sZFSdA5CQGimF+jc8jVmmOoL5M2Jbod2NRlUSxtQ7GBy44ZwUWf8BQAihLpN?= =?us-ascii?Q?/dzEpBxXuUKnqVaul1si98IPGJ9rnUk88lMU+940Kny3OdTCVi6voqN7jfNZ?= =?us-ascii?Q?U8c+cUBmygX0nXauJSJuNQQl4fbUXiJUyxCpD+YSVbXVX/+Kq0vsjFswham3?= =?us-ascii?Q?oVCQ69hBMAzPEa54hYfAbLLHWzB1TrUk0QB1g7KRBUQNrwjX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17mqUMgvLV7IP131Qt5fs53AAg2EYqgS?= X-Microsoft-Antispam-Message-Info: +BoeUoS3ucEgQssQVnoufNMtj493Wa4ggm/g7kl7N9n5c5A37afP8Af2kW77gYDphAb8/m+UnJeIbJnkXlPoi/aAIdvfq4j49VHjYTVFLzZvgWmSdOAkdS+DUbY+rBvIRxQZs0rOgO5lyfEEFeRUT/N/SawsHw7Lm0rYQVh8SMtL5eiS6u2KzEtDCRHtHny8 X-Microsoft-Exchange-Diagnostics: 1; AM5PR0402MB2771; 6:0+kvrhrH24hH0lbcT5zCr08CUFDVIdH/zQwim6iHTXDx0sDuq8ikkwcH0RSY9qw+npGJ/HYpMiUGyKXsnRCPkgNys9rICjPc2541uHj2Dw2DRkE++VznREAlnSC0SQgT4Cm8Y0M4tFX36HVgs0z8xRZFLyJVAhDYuE+f7yA7O2MaTRxuvf2e+syT2kR2T1xrSaTJ+1HgIW7ful+6Ma3QSc/dqGmrg4nJrxrln3wHukNDAYJSAoC4AvhwsZQeonOxUoGsCvknntCPBX8oS0jQgwly2hhd6zGdcWC0O+UT//vbhU9EexWT7UenBwzKiKsYI4o+/P3ZFNjv2aieOdzX5IOSQ/melACfkyy8s8fLf4x3PsdjZtXrQErUcki/KfIhVWssA7POK4Yxwgch/b1M8wDxOqvLQmE6DmnLkaD60I5rbGWfYFZ/zZtK3a/ik9o4DncaR2pafkOHsrmRNj7dwA==; 5:+kXRptaVa4yxk/S/uFtEEtcP/bIaR0AzjumDC2eLuQVM9TOlmIl9SdreQadmcask5jq8mxsiXBT4bdW5dcl/YYW3Iw8Rp5L/w2ykgPVngMT2VVbqFK3qc5Y0NBa5lnltg5abTJjTEb/39xJee8MHD167K7439clMnf8IfaRxlbE=; 24:Cue01ovY+NWgCJWe5bs+BUW+ZA9KoGnxDlLibCo3HsMoISApjOAHEbMPTT+3f+quZAfIqmEoulHNfmAk6ppcEkX2m/Df5KPp8/yyDOoHVu4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0402MB2771; 7:lCqHJ89F67EJnJKmT+dTZzigWPK96Zg3HAnSTlIyjuT0FQPIWLTltY8QtNc8gbwxaHf4cN6JjugyMzC/WojAEx6fMXHaX6dz1EKrPFcpxHujdteN0ccc5HeW6u9ruxtrscnLT8DR+Wf1QZvq2negzW/Jj7ZNDCw+xPo90v9VMbCb1G7cBGuwrOd+ET3bF+bXRQ7TZKXNchtpW8cFnI5J413Tzvr6p6rgRqdyOtH4gSYIQMq2Rhpkq1qSJu86bs8M X-MS-Office365-Filtering-Correlation-Id: f2ca1d4b-0b91-4bb8-9d09-08d5b5bf2170 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2018 15:11:23.8315 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f2ca1d4b-0b91-4bb8-9d09-08d5b5bf2170 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0402MB2771 Subject: [dpdk-stable] [PATCH 1/2] bus/fslmc: fix memory leak and cleanup X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 May 2018 15:11:27 -0000 Fixes: 828d51d8fc3e ("bus/fslmc: refactor scan and probe functions") Coverity issue: 268327 Cc: stable@dpdk.org Signed-off-by: Shreyansh Jain --- drivers/bus/fslmc/fslmc_vfio.c | 36 ++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c index 6ecd64aa2..9786143d8 100644 --- a/drivers/bus/fslmc/fslmc_vfio.c +++ b/drivers/bus/fslmc/fslmc_vfio.c @@ -572,38 +572,39 @@ fslmc_process_iodevices(struct rte_dpaa2_device *dev) static int fslmc_process_mcp(struct rte_dpaa2_device *dev) { + int ret; intptr_t v_addr; - char *dev_name; + char *dev_name = NULL; struct fsl_mc_io dpmng = {0}; struct mc_version mc_ver_info = {0}; rte_mcp_ptr_list = malloc(sizeof(void *) * 1); if (!rte_mcp_ptr_list) { DPAA2_BUS_ERR("Unable to allocate MC portal memory"); - return -ENOMEM; + ret = -ENOMEM; + goto cleanup; } dev_name = strdup(dev->device.name); if (!dev_name) { DPAA2_BUS_ERR("Unable to allocate MC device name memory"); - free(rte_mcp_ptr_list); - rte_mcp_ptr_list = NULL; - return -ENOMEM; + ret = -ENOMEM; + goto cleanup; } v_addr = vfio_map_mcp_obj(&vfio_group, dev_name); if (v_addr == (intptr_t)MAP_FAILED) { DPAA2_BUS_ERR("Error mapping region (errno = %d)", errno); - free(rte_mcp_ptr_list); - rte_mcp_ptr_list = NULL; - return -1; + ret = -1; + goto cleanup; } /* check the MC version compatibility */ dpmng.regs = (void *)v_addr; if (mc_get_version(&dpmng, CMD_PRI_LOW, &mc_ver_info)) { DPAA2_BUS_ERR("Unable to obtain MC version"); - return -1; + ret = -1; + goto cleanup; } if ((mc_ver_info.major != MC_VER_MAJOR) || @@ -613,13 +614,24 @@ fslmc_process_mcp(struct rte_dpaa2_device *dev) MC_VER_MAJOR, MC_VER_MINOR, mc_ver_info.major, mc_ver_info.minor, mc_ver_info.revision); - free(rte_mcp_ptr_list); - rte_mcp_ptr_list = NULL; - return -1; + ret = -1; + goto cleanup; } rte_mcp_ptr_list[0] = (void *)v_addr; + free(dev_name); return 0; + +cleanup: + if (dev_name) + free(dev_name); + + if (rte_mcp_ptr_list) { + free(rte_mcp_ptr_list); + rte_mcp_ptr_list = NULL; + } + + return ret; } int -- 2.17.0