From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D88C742CDA; Fri, 16 Jun 2023 14:42:07 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C5AA04161A; Fri, 16 Jun 2023 14:42:07 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2059.outbound.protection.outlook.com [40.107.220.59]) by mails.dpdk.org (Postfix) with ESMTP id 3900340DDB for ; Fri, 16 Jun 2023 14:42:06 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YpJ3H6hERfG/R+NIZEkESlz4q0tYgE7lUJfq3uHrhM1BJ+CDnrXxXeictubaxnHjH5UTOFvJaGiy1tpV6Ln1NPQkAMdyKU+129s6zd+y/lBLcGjU70XoBrDop0/NzW2JhwD3Yc2udrCLu2VlgkOGWUiGVAvQPLlkHi8XGvS+XvmJcOC/+ZOMnqmwZ1LEVhDqm4cWWew+tpXeqPD3fc52+rKu03GMnCGc9f1POXGQBPmB2HR0HpqCCMQjajHnKhIBMVEdGlJmf+P+6QiJjteX/fE+G1dUg2cyOTeDbjGfbdhOvhtgVpmd8POu2eKyuuqhd+7Zf1CpTb8SixwFV/MTAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Koe9r0iORvvsrRDxHt01rewETy2dbo8FFU4X/KemanY=; b=WUQyhgX6zfKNw/e8gyRtAvg7TFeCF+5mV4liZj4t2NF0wc9SSxNf0+yo5gL+bGKx4ivaC3pqqyAdEvapqKr8nXfikvpMT/7VSEuvON13je6NFjNZq9qJIJF6EsuwbjM1j1cVCX3fjKG1MP2B6CNm977roeikvPsoQnGQWuUkRY6sIJWcvekVQ1H/gGocD2rS+Pb2dl2boT/+xdQXqzt4iO2E5hkVSz4saUelrhZG6aU6FEFKxRoYwGDZkNYg7fGPs+0iek8VvYeh0OCSbrGM+129fR3hR5gFLvDeLzP2c0NoqEI88l8sDivsACJxTA9LhInhkDPkdpzl8obcEZz6eg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=dpdk.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Koe9r0iORvvsrRDxHt01rewETy2dbo8FFU4X/KemanY=; b=pR1J8g2PTnu46vQ3r6uyYUOBpJBBajC09HTd0D6R4XQDIkPPBB1nMInVMZgZNvmx4GRWAyeumTcin/yZp0PXOedVA0hE/Ue4G8tsm7KiGTXG+E4uOW7C3lP87dwQbYNwaNbWNH4icyUeJUyZCcIlhhkQmH7jn8xIYEwgVNwJB/g= Received: from BN0PR04CA0146.namprd04.prod.outlook.com (2603:10b6:408:ed::31) by CH3PR12MB7620.namprd12.prod.outlook.com (2603:10b6:610:150::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.25; Fri, 16 Jun 2023 12:42:04 +0000 Received: from BN8NAM11FT084.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ed:cafe::3e) by BN0PR04CA0146.outlook.office365.com (2603:10b6:408:ed::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.29 via Frontend Transport; Fri, 16 Jun 2023 12:42:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT084.mail.protection.outlook.com (10.13.176.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.29 via Frontend Transport; Fri, 16 Jun 2023 12:42:03 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 16 Jun 2023 07:42:02 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.6; Fri, 16 Jun 2023 05:42:02 -0700 Received: from xhdipdslab59.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.23 via Frontend Transport; Fri, 16 Jun 2023 07:42:01 -0500 From: Abhijit Gangurde To: , CC: , , , Abhijit Gangurde Subject: [PATCH v2 3/3] bus/cdx: fix resource leak Date: Fri, 16 Jun 2023 18:09:10 +0530 Message-ID: <20230616123910.1110724-4-abhijit.gangurde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230616123910.1110724-1-abhijit.gangurde@amd.com> References: <20230616123910.1110724-1-abhijit.gangurde@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT084:EE_|CH3PR12MB7620:EE_ X-MS-Office365-Filtering-Correlation-Id: 271db4be-2b25-449c-f0d2-08db6e671640 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 41dHxwOxVqQU3zzkXXY8u2U35YnxiYljvpbQrbmumvsMzmXygyrdrCvOKIYoMDwhJbSeEiCDb3AT8LYIftJ1mH17fmgCsdvMfP8BlLkAL8Z8Vek8Yy4wVXKSaTYN0rS0ZKOfWEmEFp2pSCCMuPrnelrOG6Ut/2sx6Intd9raxCcn4G1F2JMY6XmG1gQUwPKnG4q7IOfdAvVtlLZClFNV0GWsFdqPqqytJr30JCmjqIfJ/2Iy+PqCTlkQxWe1xNd4L84+zUVRrnvpK1GBK8/pom3uVBbvk6jP3XpZwjnWpu0bDZMD9QNmnfYb6fYmNi3ZhG9d28L82Opn1a9QFEFs7jTjZHf8nWtIGohxChi/xIw8oYDOHRp0bMfVHF0YVgDemVZQjwoELJPzirJp4UMmt3hfuOYomKGgy50JPmOLAgKg0YlSdiqdK2EENFF+5jxeI65S04jrmk7Kla7lfenkWvr24gYYSCdCFMKPTsd5VNGTwA3PWGFSsTpFbx5qdWXWHf4ZSHiF44vjP/+uAy7ue8JTRfOS0zdgA4EJXfP3zbzUhXxJV9hfd/6OHiO105rYD9cfT1Smrw9bCAf3RL25ubXSWjEFeygagdfNeh3W8Z124FR9w13XEzXlQREzM4VsPHCLNQ3WgEwXGApwkOR4QEljgp6jQIahKh8tA4jtgYwNIkysmUBFqnpT4t97azwArq4ML1eu6Oi3bmJ9MwYWS2JCaOiralE8jDN5JmQFMNnll9cLsL4wxz0WY7lJ0nPzDL5p/bZpQgtPm++u4qCAGA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(136003)(396003)(346002)(39860400002)(376002)(451199021)(40470700004)(36840700001)(46966006)(44832011)(70586007)(6636002)(4326008)(2906002)(86362001)(316002)(70206006)(41300700001)(110136005)(8936002)(5660300002)(8676002)(54906003)(40480700001)(82310400005)(478600001)(81166007)(6666004)(82740400003)(356005)(40460700003)(83380400001)(26005)(186003)(2616005)(36756003)(426003)(1076003)(336012)(47076005)(36860700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2023 12:42:03.6629 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 271db4be-2b25-449c-f0d2-08db6e671640 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT084.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7620 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Free the allocated device memory and interrupt handler on error scenarios. Coverity issue: 385377 Fixes: f29fb5caa135 ("bus/cdx: support MSI") Signed-off-by: Abhijit Gangurde --- v2: - Updated commit message drivers/bus/cdx/cdx.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/bus/cdx/cdx.c b/drivers/bus/cdx/cdx.c index aef19682f4..f9526e08cc 100644 --- a/drivers/bus/cdx/cdx.c +++ b/drivers/bus/cdx/cdx.c @@ -208,8 +208,8 @@ cdx_scan_one(const char *dirname, const char *dev_name) ret = cdx_get_kernel_driver_by_path(filename, driver, sizeof(driver)); if (ret < 0) { CDX_BUS_ERR("Fail to get kernel driver"); - ret = -1; - goto err; + free(dev); + return -1; } /* Allocate interrupt instance for cdx device */ @@ -218,6 +218,7 @@ cdx_scan_one(const char *dirname, const char *dev_name) if (dev->intr_handle == NULL) { CDX_BUS_ERR("Failed to create interrupt instance for %s", dev->device.name); + free(dev); return -ENOMEM; } @@ -241,8 +242,8 @@ cdx_scan_one(const char *dirname, const char *dev_name) /* get device id */ snprintf(filename, sizeof(filename), "%s/device", dirname); if (eal_parse_sysfs_value(filename, &tmp) < 0) { - free(dev); - return -1; + ret = -1; + goto err; } dev->id.device_id = (uint16_t)tmp; @@ -251,6 +252,7 @@ cdx_scan_one(const char *dirname, const char *dev_name) return 0; err: + rte_intr_instance_free(dev->intr_handle); free(dev); return ret; } -- 2.25.1