From patchwork Thu Jul 14 09:10:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiang Yu X-Patchwork-Id: 9229153 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1461C60574 for ; Thu, 14 Jul 2016 07:45:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05EFD28066 for ; Thu, 14 Jul 2016 07:45:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED1FE2815E; Thu, 14 Jul 2016 07:45:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D27628066 for ; Thu, 14 Jul 2016 07:45:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D42906E87C; Thu, 14 Jul 2016 07:44:53 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0080.outbound.protection.outlook.com [104.47.40.80]) by gabe.freedesktop.org (Postfix) with ESMTPS id DC6706E717; Thu, 14 Jul 2016 07:44:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=9C1MSlJYWasMk+Q5ZiDfLV+RZkiMZy6wX809JZh5T70=; b=XtCIKU3g17U1mTAfb3wSsYA9cpxracPh+aAaDHFcUni2mhlDH17LROdBu9oaP1vsVXu8ZqzfxuuPu05TAUqwER2yLPSnzViq2h4fnGWk2AkvI/3h195wJah71kLzC2hNxrobK1WSdWKDIGR613ALl9vK9XOADawHQs/3o/4ours= Received: from BN1PR12CA0033.namprd12.prod.outlook.com (10.160.77.43) by CY1PR12MB0278.namprd12.prod.outlook.com (10.161.174.16) with Microsoft SMTP Server (TLS) id 15.1.523.12; Thu, 14 Jul 2016 07:44:50 +0000 Received: from DM3NAM03FT048.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::200) by BN1PR12CA0033.outlook.office365.com (2a01:111:e400:49::43) with Microsoft SMTP Server (TLS) id 15.1.528.16 via Frontend Transport; Thu, 14 Jul 2016 07:44:49 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.21) smtp.mailfrom=amd.com; gmail.com; dkim=none (message not signed) header.d=none; gmail.com; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.21) by DM3NAM03FT048.mail.protection.outlook.com (10.152.83.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.539.16 via Frontend Transport; Thu, 14 Jul 2016 07:44:49 +0000 Received: from SATLEXDAG01.amd.com (10.181.40.3) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server (TLS) id 14.3.266.1; Thu, 14 Jul 2016 02:44:36 -0500 Received: from SCYBEXDAG04.amd.com (10.34.11.14) by SATLEXDAG01.amd.com (10.181.40.3) with Microsoft SMTP Server (TLS) id 14.3.266.1; Thu, 14 Jul 2016 03:44:36 -0400 Received: from shlnxcqesrv2.amd.com (10.237.70.153) by SCYBEXDAG04.amd.com (10.34.11.14) with Microsoft SMTP Server id 14.3.266.1; Thu, 14 Jul 2016 15:44:31 +0800 From: Qiang Yu To: Subject: [libdrm][PATCH v2 2/2] drm: fix multi GPU drmFreeDevices memory leak Date: Thu, 14 Jul 2016 17:10:56 +0800 Message-ID: <1468487456-28666-2-git-send-email-Qiang.Yu@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1468487456-28666-1-git-send-email-Qiang.Yu@amd.com> References: <1468487456-28666-1-git-send-email-Qiang.Yu@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.21; IPV:CAL; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(428002)(199003)(189002)(86362001)(105586002)(87936001)(7846002)(26826002)(2351001)(229853001)(8936002)(50226002)(101416001)(106466001)(92566002)(5003940100001)(76176999)(48376002)(50986999)(246002)(19580405001)(8676002)(189998001)(110136002)(47776003)(7696003)(53416004)(50466002)(4326007)(36756003)(77096005)(5003600100003)(586003)(11100500001)(356003)(2906002)(19580395003)(305945005)(2950100001)(5001870100001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR12MB0278; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; PTR:hybridsmtp01.amd.com,hybridsmtp.amd.com; A:1; MX:1; LANG:en; X-MS-Office365-Filtering-Correlation-Id: 15ef2900-e7dd-4025-6d9e-08d3abbabbf8 X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0278; 2:V+N+vu7/FYQPDpv5/Mfo7mQcVz9dVoBJ3nP8uVk1LFoEmNO/1dvg7whBEDneUk90zc5TAShN+dVjbnjfjMP37dNnGXUjLuoOr/kLz+w7oOs7NCvnbx1AdcCzkhrvOy3PmCcmBSZSHDWPjs4SUotJyfhCFyL3IofH5rIuLOeTlUMrxASKB6ck5KN0xT/QSbVT; 3:JLcfRh9HsvP6IZAPN/jjD4JgCps9rzUmHfhjibWkSJ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nostics: 1; CY1PR12MB0278; 20:CCaFL/WdAgwOfGFyNGPayLT1Uk9U/A2wLDC2LEH8qNGJvCgevAxajXL+SLKnZ7lKrCqURIrjRqVmE13Y0AeMTdirTdraytIqp9QIlKd7n0I/6eu7MlbyQoO8aIwAM326IMJv68gmiTiQx8HFX5tYiLFtYTT7jc2VjXmxhftoAlC9/cPKXEOZL5c0ePNNBDwx+M2XdMtyd85RJ3QNwp+eVj/8Thbpe9Xi3cWb9A1gOvzYzrr6Q6yH8AQkxJBS57tyAibagb/eA0/zrewiGEt2JMqACsH+Sn5EFiKDyzV7rTwN3Ile8Ixc2KVyET2MMJjQBsDFdLCeRJadQRUXqGWZ0DOwLnoL5Ph2LlgdjQvbmXGlqVzV5Gv+zIzH4gOE5zXMsKiIv7xkV4RgDd/vkH8XA3uz90iO1UZlB4xwz5Ao595lwasONTiPn7HhEwXzlipDafTBn1e1Lqnk6bHLET3+AZSsNiMwPBXC+5UNE3YyPjhA3raBwGZ0awp2GZJW0QGV X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(131327999870524)(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13023025)(8121501046)(5005006)(13013025)(13021025)(10201501046)(3002001)(6055026); SRVR:CY1PR12MB0278; BCL:0; PCL:0; RULEID:; SRVR:CY1PR12MB0278; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0278; 4:V+BQY6kwLc5BtalLNbvUNn8QgTqAw4Wo7VDSFPKC9hQDoK8N0NiUuw6jksxTYsdk5aGfI77lDJOte9hp6BReVyWLOjnLirjh4bw1BpX7rqenwn+bKLaEZT7BN7bBfWon4eFlqHKB2W0nK2ZZRRkF0PzZmAUJpJ/UnRhaQrPFYY22bZl02azMM571x8t34h1LoNAr8efpF1kX/ZEeK8o1HOu3W/bqFXUM3yAykcKGcf4iIQcKgCUF7rTM96xw2BEXVVxGItUnq+Ua45vxp7DcHgqbMn/+Q22eruv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Fr19s9nYPn+rSYJ0/YHhDBHfxneTndJkaXE2gmTUmWnS58QvUMzlTwAZm87aGaDFXdG94xA3mR5/lq20dCg==; 24:tj3B1AFRdtVfRw7mQ+h5YlftDHP943tm97DHG1g8s0lsNaAXe4z9jwbGD5iSSr7wSY7EvV/3ObqAcrCo5rCQjm83w9I+20nGQzDkil+AX6g=; 7:604dngn00u+1C7k+zn7LkXIaXSVzOf1DaXkIbkDUXusjbo6deSDtEmKtXlVBrkTuTHNFwzNqoLXbDOVgQc41HMqFf1FkNMhUkmycetfJQyXyvW5qL/EB2msNZkvvIQIvj/++3i3i4CBSDtTn/YWBW9PI87sq7SLXjYYHA03AuHsfpBBOBIqtId9z3n8gDRvrTw7QExlkRgoFwE6gej7IgFxMaX2R69ZCuvxaEL0rFJ+1mSXf3pnDsZJ6eGX2LUUG SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0278; 20:MTwPQ4g2nN8ZwzjraAtzJpwY6HTdGugvQACeZ/pKt70cK1HhyRnJmScaqDXvNE+4NdZ6CHm9g1quFRU3Ly72/GXLHxiKmMp+7cn5MjbsvL0fsMeSjmxg2yKSyrmZaoi3QjBd3TEv5q1IBSiG6gOkbUQoqKW5TdOSPqaX6d89WP9DH8osbp53DJA6qZ+wEZFKIg3ZS+J0jgxUBgft8KBT5nPIPa7ydCkbDbu+4EooxjM0UqSKJuWyOD8YCco6NBPh X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2016 07:44:49.3224 (UTC) 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.21]; Helo=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0278 Cc: Qiang Yu , Emil Velikov , dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP When in multi GPU case, devices array may have some NULL "hole" in between two devices. So check all array elements and free non-NULL device. Change-Id: Ifc32d240f895059bc4b19138cb81de38d99fb88a Signed-off-by: Qiang Yu --- xf86drm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xf86drm.c b/xf86drm.c index 19001db..32bedeb 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -2992,8 +2992,9 @@ void drmFreeDevices(drmDevicePtr devices[], int count) if (devices == NULL) return; - for (i = 0; i < count && devices[i] != NULL; i++) - drmFreeDevice(&devices[i]); + for (i = 0; i < count; i++) + if (devices[i]) + drmFreeDevice(&devices[i]); } static int drmProcessPciDevice(drmDevicePtr *device, const char *d_name,