From patchwork Fri Feb 17 17:54:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Starkey X-Patchwork-Id: 9580461 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 E93A4600C5 for ; Fri, 17 Feb 2017 17:54:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DADC828742 for ; Fri, 17 Feb 2017 17:54:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CCB6A28766; Fri, 17 Feb 2017 17:54:38 +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 5DC1E28742 for ; Fri, 17 Feb 2017 17:54:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BE7A26E334; Fri, 17 Feb 2017 17:54:37 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from foss.arm.com (foss.arm.com [217.140.101.70]) by gabe.freedesktop.org (Postfix) with ESMTP id E822C6E32F for ; Fri, 17 Feb 2017 17:54:36 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B4FFD344; Fri, 17 Feb 2017 09:54:36 -0800 (PST) Received: from e106950-lin.cambridge.arm.com (e106950-lin.cambridge.arm.com [10.2.133.193]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 22E053F578; Fri, 17 Feb 2017 09:54:36 -0800 (PST) From: Brian Starkey To: intel-gfx@lists.freedesktop.org Date: Fri, 17 Feb 2017 17:54:26 +0000 Message-Id: <1487354070-14487-1-git-send-email-brian.starkey@arm.com> X-Mailer: git-send-email 1.7.9.5 Subject: [Intel-gfx] [PATCH i-g-t 1/5] lib/igt_kms: Fix drm_plane leak X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP In the loop looking for planes on a pipe, we always want to free up the drm_plane afterwards. Fixes: 36656239ef96 lib/igt_kms: Implement dynamic plane count support Signed-off-by: Brian Starkey Reviewed-by: Robert Foss --- Hi, This series cleans up igt_display_init a bit. - Fixes a memory leak. - Fixes out-of-bounds array access on cards with no primary plane. - Fixes memory corruption/crashes on cards with no cursor plane. - Cleans up some left-over stuff which wasn't really relevant after the dynamic planes change. There's one detail (patch 4) I'm not really sure about - the dynamic planes stuff means that the "drm_plane-less" cursor plane doesn't work/make sense anymore, as it will never be found by igt_pipe_get_plane_type(). I couldn't find any tests which seemed to rely on having that cursor plane present, but I don't have any hardware with a cursor to test on. igt_display_init() could be simplified a bit further by not putting the primary/cursor planes at the start/end respectively, but at least kms_cursor_legacy appears to rely on a non-cursor plane being index 0, so I've left it as-is for now. I've given this a cursory test on Mali-DP, but if anyone is able to test it more thoroughly on Intel HW that might be a good idea. -Brian lib/igt_kms.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index f59af6e75348..4ca9145726e2 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -1759,12 +1759,10 @@ void igt_display_init(igt_display_t *display, int drm_fd) plane_resources->planes[j]); igt_assert(drm_plane); - if (!(drm_plane->possible_crtcs & (1 << i))) { - drmModeFreePlane(drm_plane); - continue; - } + if (drm_plane->possible_crtcs & (1 << i)) + n_planes++; - n_planes++; + drmModeFreePlane(drm_plane); } igt_assert_lte(0, n_planes);