From patchwork Thu Mar 16 02:00:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seung-Woo Kim X-Patchwork-Id: 9626939 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 DFB60604A9 for ; Thu, 16 Mar 2017 02:00:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C648B28610 for ; Thu, 16 Mar 2017 02:00:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BABD728636; Thu, 16 Mar 2017 02:00:17 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 B94F728616 for ; Thu, 16 Mar 2017 02:00:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E06606E0D8; Thu, 16 Mar 2017 02:00:14 +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 EDB1D6E301 for ; Thu, 16 Mar 2017 02:00:13 +0000 (UTC) Received: from epcas1p2.samsung.com (unknown [182.195.41.46]) by mailout2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OMV02KKYXJU34C0@mailout2.samsung.com> for dri-devel@lists.freedesktop.org; Thu, 16 Mar 2017 10:59:54 +0900 (KST) Received: from epsmges1p4.samsung.com (unknown [182.195.40.65]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20170316015953epcas1p44bf44441a10741c742ff51c8779d7948~sOjkm09EF0770007700epcas1p4b; Thu, 16 Mar 2017 01:59:53 +0000 (GMT) Received: from epcas1p2.samsung.com ( [182.195.41.46]) by epsmges1p4.samsung.com (Symantec Messaging Gateway) with SMTP id AB.9A.06770.891F9C85; Thu, 16 Mar 2017 10:59:52 +0900 (KST) Received: from epcpsbgm1new.samsung.com (u26.gpu120.samsung.co.kr [203.254.230.26]) by epcas1p2.samsung.com (KnoxPortal) with ESMTP id 20170316015952epcas1p20a285e6029d1b94cb32b1fca2aeb1d18~sOjjSh3qT3005430054epcas1p28; Thu, 16 Mar 2017 01:59:52 +0000 (GMT) X-AuditID: b6c32a38-f79f06d000001a72-fa-58c9f19857af Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 70.90.06425.891F9C85; Thu, 16 Mar 2017 10:59:52 +0900 (KST) Received: from localhost.localdomain ([10.113.62.209]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OMV003XQXJQCW80@mmp1.samsung.com>; Thu, 16 Mar 2017 10:59:52 +0900 (KST) From: Seung-Woo Kim To: dri-devel@lists.freedesktop.org, robclark@freedesktop.org, inki.dae@samsung.com Subject: [PATCH libdrm] tests/exynos: fix memory issues of error path in g2d test Date: Thu, 16 Mar 2017 11:00:04 +0900 Message-id: <1489629604-10811-1-git-send-email-sw0312.kim@samsung.com> X-Mailer: git-send-email 1.7.4.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBKsWRmVeSWpSXmKPExsWy7bCmnu6MjycjDBru2lhc+fqezWLP1XtM FpPuT2CxeHHvIovFlOZcixmTX7I5sHms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SW1 SCE1Lzk/JTMv3VYpNMRN10JJIS8xN9VWKULXNyRISaEsMacUyDMyQAMOzgHuwUr6dgluGQf3 XWYuOC9Q8W/aDuYGxum8XYycHBICJhLPP+xhhLDFJC7cW8/WxcjFISSwlFGidVs3C4Tzg1Hi /ISH7CBVbAI6EvuX/GYFsUUEQiW2Lf3EBGIzC/hKPL8/gRnEFhYIlrh38StYPYuAqkTn23Ng G3gF3CQmnrjNBrFNQWLBvbdsExi5FzAyrGKUSC1ILihOSs81zEst1ytOzC0uzUvXS87P3cQI DshnUjsYD+5yP8QowMGoxMM7wfdkhBBrYllxZe4hRgkOZiUR3quvgEK8KYmVValF+fFFpTmp xYcYTYEOmMgsJZqcD4yWvJJ4QxNzE3NjAwtzS0sTIyVx3sbZz8KFBNITS1KzU1MLUotg+pg4 OKUaGLWUpkb8Fn2bO6t1iqfJ3QNT+fxfe5y4rKIocH6jXcJvkbIFRVKMB/Y9MU150PWjzlTE piDq46zTV47He7UKdvE/Fr37zJarXCo0SkjooBBXyhNz1z0LlAWOpDLmGs9285r2bJJIjN7M P/kc6YHie93E85LOvLSI/Nz97tGDvwIscz+6t4uJKrEUZyQaajEXFScCAEerRvZeAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170316015952epcas1p20a285e6029d1b94cb32b1fca2aeb1d18 X-Msg-Generator: CA X-Sender-IP: 203.254.230.26 X-Local-Sender: =?UTF-8?B?6rmA7Iq57JqwG1RpemVuIFBsYXRmb3JtIExhYihTL1fshLw=?= =?UTF-8?B?7YSwKRvsgrzshLHsoITsnpAbU2VuaW9yIEVuZ2luZWVy?= X-Global-Sender: =?UTF-8?B?U2V1bmctV29vIEtpbRtUaXplbiBQbGF0Zm9ybSBMYWIuG1Nh?= =?UTF-8?B?bXN1bmcgRWxlY3Ryb25pY3MbU2VuaW9yIEVuZ2luZWVy?= X-Sender-Code: =?UTF-8?B?QzEwG1NUQUYbQzEwVjgxMTE=?= CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-HopCount: 7 X-CMS-RootMailID: 20170316015952epcas1p20a285e6029d1b94cb32b1fca2aeb1d18 X-RootMTR: 20170316015952epcas1p20a285e6029d1b94cb32b1fca2aeb1d18 References: Cc: sw0312.kim@samsung.com, emil.l.velikov@gmail.com 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: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch fixes memory issues including NULL deference and leak in g2d test in error path. Signed-off-by: Seung-Woo Kim --- tests/exynos/exynos_fimg2d_test.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/exynos/exynos_fimg2d_test.c b/tests/exynos/exynos_fimg2d_test.c index 797fb6e..2177e08 100644 --- a/tests/exynos/exynos_fimg2d_test.c +++ b/tests/exynos/exynos_fimg2d_test.c @@ -59,7 +59,6 @@ static void connector_find_mode(int fd, struct connector *c, if (!connector) { fprintf(stderr, "could not get connector %i: %s\n", resources->connectors[i], strerror(errno)); - drmModeFreeConnector(connector); continue; } @@ -98,7 +97,6 @@ static void connector_find_mode(int fd, struct connector *c, if (!c->encoder) { fprintf(stderr, "could not get encoder %i: %s\n", resources->encoders[i], strerror(errno)); - drmModeFreeEncoder(c->encoder); continue; } @@ -264,7 +262,8 @@ static int g2d_copy_test(struct exynos_device *dev, struct exynos_bo *src, userptr = (unsigned long)malloc(size); if (!userptr) { fprintf(stderr, "failed to allocate userptr.\n"); - return -EFAULT; + ret = -EFAULT; + goto fail; } src_img.user_ptr[0].userptr = userptr; @@ -469,7 +468,8 @@ static int g2d_copy_with_scale_test(struct exynos_device *dev, userptr = (unsigned long)malloc(size); if (!userptr) { fprintf(stderr, "failed to allocate userptr.\n"); - return -EFAULT; + ret = -EFAULT; + goto fail; } src_img.user_ptr[0].userptr = userptr; @@ -557,7 +557,8 @@ static int g2d_blend_test(struct exynos_device *dev, userptr = (unsigned long)malloc(size); if (!userptr) { fprintf(stderr, "failed to allocate userptr.\n"); - return -EFAULT; + ret = -EFAULT; + goto fail; } src_img.user_ptr[0].userptr = userptr; @@ -755,7 +756,7 @@ int main(int argc, char **argv) dev = exynos_device_create(fd); if (!dev) { - drmClose(dev->fd); + drmClose(fd); return -EFAULT; }