From patchwork Tue Mar 20 03:47:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 10296295 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 20BCF60385 for ; Tue, 20 Mar 2018 03:47:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1268C28484 for ; Tue, 20 Mar 2018 03:47:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06465284AF; Tue, 20 Mar 2018 03:47:59 +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=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]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EA43D28484 for ; Tue, 20 Mar 2018 03:47:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 922A06E0B2; Tue, 20 Mar 2018 03:47:54 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by gabe.freedesktop.org (Postfix) with ESMTPS id 62B976E0B2 for ; Tue, 20 Mar 2018 03:47:53 +0000 (UTC) Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20180320034751epoutp02929799a7dfb1ca75269af4bacee69747~dhEK25Rc_3212432124epoutp02J; Tue, 20 Mar 2018 03:47:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20180320034751epoutp02929799a7dfb1ca75269af4bacee69747~dhEK25Rc_3212432124epoutp02J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1521517671; bh=8RK4P3XKdWLkpEMSvTzT15EJ6LeFeWKv7IAVSVEEn70=; h=From:To:Cc:Subject:Date:References:From; b=lgnq2RsmaXLE3UpR165JE2Znhv30B0qUAE0desqacCXs4jGSf+aBbg5GbP7rBo8D7 xANnn7wVlUOsbkvdOUM9scfGmwgnhSnlm9T76yzNqv0szre6uhlADc4wdwn/wdXWGx yljSG9J315eCEwlTd6XsyBMxzraiMJU2+PJc6DKU= Received: from epsmges2p3.samsung.com (unknown [182.195.40.68]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20180320034750epcas1p4afb210fe6e15364fe711f1a2ed3c17c4~dhEKa3DaP2057320573epcas1p4N; Tue, 20 Mar 2018 03:47:50 +0000 (GMT) Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id 49.40.04108.66480BA5; Tue, 20 Mar 2018 12:47:50 +0900 (KST) Received: from epsmgms2p2new.samsung.com (unknown [182.195.42.143]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20180320034749epcas2p16a55f30ea5937dfb720c2308c0d9a645~dhEJtJhAl1248812488epcas2p1q; Tue, 20 Mar 2018 03:47:49 +0000 (GMT) X-AuditID: b6c32a47-19fff7000000100c-42-5ab08466b079 Received: from epmmp2 ( [203.254.227.17]) by epsmgms2p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 6A.3E.03890.56480BA5; Tue, 20 Mar 2018 12:47:49 +0900 (KST) Received: from daeinki-desktop.tn.corp.samsungelectronics.net ([10.113.62.206]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P5V0083QEJP9N80@mmp2.samsung.com>; Tue, 20 Mar 2018 12:47:49 +0900 (KST) From: Inki Dae To: dri-devel@lists.freedesktop.org Subject: [RESEND PATCH libdrm] tests: fix memory leak issue Date: Tue, 20 Mar 2018 12:47:33 +0900 Message-id: <1521517653-4310-1-git-send-email-inki.dae@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPIsWRmVeSWpSXmKPExsWy7bCmmW5ay4Yog223tSyufH3PZjHp/gQW i9u/+RyYPe53H2fy6G1+x+bRt2UVYwBzVKpNRmpiSmqRQmpecn5KZl66rZJ3cLxzvKmZgaGu oaWFuZJCXmJuqq2Si0+ArltmDtAiJYWyxJxSoFBAYnGxkr6dTVF+aUmqQkZ+cYmtUrShoZGe oYG5npGRkZ6JcayVkSlQSUJqxu/Z85gL9ghULF14lbmB8QJvFyMHh4SAicSyWSJdjFwcQgI7 GCXWnXnFCOF8Z5S48aCHpYuRE6xo/t6tzBCJDYwSnx69YoNwJjJJvH33jRWkik1AVWLiivts ILaIgLLE34mrGEFsZgFziZ8v/7OD2MIC1hLrmzvB6lmA6tt+PwKr5xVwlmjbfJMNYpucxMlj k1lBFkgInGSV2PtqLStEwkXizNV+qJOEJV4d38IOYUtLPFu1kRGioZ1RYtfZ62wQTg+jxPLF i6CqjCWeLexigjiJT6Lj8F92SAjwSnS0CUGUeEg8v7+fCcJ2lDhxagXYYiGBWImLz/+wTmCU XMDIsIpRLLWgODc9tdiowFivODG3uDQvXS85P3cTIzjytdx3MG4753OIUYCDUYmHV+PO+igh 1sSy4srcQ4wSHMxKIrzq0RuihHhTEiurUovy44tKc1KLDzGaAgNkIrOUaHI+MCnllcQbmlga mJiZGZmbWQCTgDhva4BLlJBAemJJanZqakFqEUwfEwenVANjxFqFhBd2hQaTa7iXXj6uNnX+ JLll7+zNPZiXXQnom6+3X2Zb3/0/60w/7pUJZdWLV/6QknxDMmhHhQjbHf6fYR/qzrYfWvnD 8MavAM0/sRLzBXmOPVqtnqNeu17Iz2a3yAnB48dlr8ounudUn5o7JXtzXNRsU+cjNX91v21t /DGFJ/RZRbiQEktxRqKhFnNRcSIASuMREhIDAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKJMWRmVeSWpSXmKPExsVy+t9jQd3Ulg1RBs/fmltc+fqezWLS/Qks Frd/8zkwe9zvPs7k0dv8js2jb8sqxgDmKC6blNSczLLUIn27BK6M37PnMRfsEahYuvAqcwPj Bd4uRk4OCQETifl7tzJ3MXJxCAmsY5TYt/QFM0hCSGAyk8TSfhUQm01AVWLiivtsILaIgLLE 34mrGEFsZgFziZ8v/7OD2MIC1hLrmztZQWwWoPq234/A6nkFnCXaNt9kg1gmJ3Hy2GTWCYxc CxgZVjFKphYU56bnFhsVGOWllusVJ+YWl+al6yXn525iBHp222Gt/h2Mj5fEH2IU4GBU4uHV uLM+Sog1say4MvcQowQHs5IIr3r0high3pTEyqrUovz4otKc1OJDjNIcLErivPz5xyKFBNIT S1KzU1MLUotgskwcnFINjDNPPLsxYardw7sLI786hjyWUTjCaX0y1KGmaMc+F/HIAONFS3fO Nc5NXGuQu6hT6vjzf1tnfq7/4bP9X8J5cx/zJidX3rPiu+64eR+U+p2bfehz4+OpEhunLpTZ KGXelHVi+broKp9ZMyNV5U7eX3g4QNVCS/VVpecBM4Zf2xLMIhX3fWAIe6PEUpyRaKjFXFSc CADICfj56AEAAA== X-CMS-MailID: 20180320034749epcas2p16a55f30ea5937dfb720c2308c0d9a645 X-Msg-Generator: CA CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20180320034749epcas2p16a55f30ea5937dfb720c2308c0d9a645 X-RootMTR: 20180320034749epcas2p16a55f30ea5937dfb720c2308c0d9a645 References: X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: treding@nvidia.com MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Fixed memory leak issue to drmModeRes and drmModePlaneRes objects. These objects were allocated by drmModeGetResources and drmModeGetPlaneResources functions but not freed properly. So this patch frees them by calling drmModeFreeResources drmModeFreePlaneResources functions at failure case. Signed-off-by: Inki Dae --- tests/kms/libkms-test-device.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/kms/libkms-test-device.c b/tests/kms/libkms-test-device.c index 53c7349..042ae05 100644 --- a/tests/kms/libkms-test-device.c +++ b/tests/kms/libkms-test-device.c @@ -67,7 +67,7 @@ static void kms_device_probe_screens(struct kms_device *device) device->screens = calloc(res->count_connectors, sizeof(screen)); if (!device->screens) - return; + goto err_free_resources; for (i = 0; i < res->count_connectors; i++) { unsigned int *count; @@ -97,6 +97,7 @@ static void kms_device_probe_screens(struct kms_device *device) device->num_screens++; } +err_free_resources: drmModeFreeResources(res); } @@ -112,7 +113,7 @@ static void kms_device_probe_crtcs(struct kms_device *device) device->crtcs = calloc(res->count_crtcs, sizeof(crtc)); if (!device->crtcs) - return; + goto err_free_resources; for (i = 0; i < res->count_crtcs; i++) { crtc = kms_crtc_create(device, res->crtcs[i]); @@ -123,6 +124,7 @@ static void kms_device_probe_crtcs(struct kms_device *device) device->num_crtcs++; } +err_free_resources: drmModeFreeResources(res); } @@ -138,7 +140,7 @@ static void kms_device_probe_planes(struct kms_device *device) device->planes = calloc(res->count_planes, sizeof(plane)); if (!device->planes) - return; + goto err_free_resources; for (i = 0; i < res->count_planes; i++) { plane = kms_plane_create(device, res->planes[i]); @@ -149,6 +151,7 @@ static void kms_device_probe_planes(struct kms_device *device) device->num_planes++; } +err_free_resources: drmModeFreePlaneResources(res); }