From patchwork Mon Mar 20 09:40:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9633569 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 7A2616020B for ; Mon, 20 Mar 2017 09:45:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7320427F9F for ; Mon, 20 Mar 2017 09:45:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6771427FAE; Mon, 20 Mar 2017 09:45:20 +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=-3.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM 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 EB2B427F9F for ; Mon, 20 Mar 2017 09:45:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 16EAB6E50A; Mon, 20 Mar 2017 09:45:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.130]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8DDCF6E50A; Mon, 20 Mar 2017 09:45:17 +0000 (UTC) Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.129]) with ESMTPA (Nemesis) id 0Le9EG-1cQS0z0mvk-00pt94; Mon, 20 Mar 2017 10:45:05 +0100 From: Arnd Bergmann To: Daniel Vetter , Jani Nikula , David Airlie Subject: [PATCH 1/3] drm/i915: allocate mock file pointer dynamically Date: Mon, 20 Mar 2017 10:40:27 +0100 Message-Id: <20170320094335.1266306-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:TXFySHDhzHIBwSnumldBcbb6fC67fLJzYgx9DYBCsLf+MSEziup nf5lukcjMm/rZ47xHcQ9XaRuOgBmP+SKTjbK90Lthl6DcvpkQpXzVzWSY0VvWMfnWto7WE1 6TONK1ICfS/fdU4Zq9kPWs506NWrRhKVA5BRsz9GBqulwuTeWmDDKE1sNK+3ZugsbWDx+Z7 szws4aqpWrlx1BSjcCBfA== X-UI-Out-Filterresults: notjunk:1; V01:K0:y53TKzcA1DU=:oqgQZLKYSlh9AUutNLQZyF a/MrWmp8vKKD3laQEKgHfOHDRNtYH4TGKWePMbLfnyp1waDfqufq3ZT5VmdpZzMl/MuL9aAl5 6EFdID4SfGX8sHfgi4vkjfr4kFCAT6I8+Cc8an2bacHQBHwuxQ6fy7pqyaZuKBpRnf6nx0O0R PdL+W7u18mYyFnNCrj4W5St/MACO9lPTjWaWWWdPp1OeMb3GzKQYejHImuAxRNK276r5pa3Ih KxlqQYg8FwUNmrBCTyQHB14vvQ7RulbM2LM/A7bY5nCN6y3eCIgnc68MjBYTuiwUQ85Stu6Pd t/fytmpFMmpqeFcX/heUys2waBPycJ7vhjszv774QhcxQc39r3LAP1vLfTldarSxUtZGyhWxo rUA7yFesJSlgLWuNG33hxVCnjVP2FxYrLVih3bUOCIPn0/9qYNIDZFiB9X7MCPEVtgn8i9nQ9 nn1qbK4V5VqpcRIO5NoAQ19jln0uQTJ9Wexx/c0AXGM9g9vpHwp8IjfRGG/+reBSGwjWnpEqe HwMcZ2GzpXofOFvmZR0bPcui4uTMnTRCEPQQX0MIW2UvGwp1yOGPWT1qo8r9XOiqxp6AbrwQ4 3HTBxc88W/0/ej1Q9DzmC6CEUvw7SdeZE6+V9IFtL/TBvEExgzqunuQpSpSOFdNaE29WKErgx SSl/h6EA4FUKMDvhdqQnQGOCH8cgoIMH94g4uYweUX4argAn7+G8No64YcSFHPdb5WIM= Cc: Arnd Bergmann , Tvrtko Ursulin , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Matthew Auld 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 A struct file is a bit too large to put on the kernel stack in general and triggers a warning for low settings of CONFIG_FRAME_WARN: drivers/gpu/drm/i915/selftests/mock_drm.c: In function 'mock_file': drivers/gpu/drm/i915/selftests/mock_drm.c:46:1: error: the frame size of 1328 bytes is larger than 1280 bytes [-Werror=frame-larger-than=] drivers/gpu/drm/i915/selftests/mock_drm.c: In function 'mock_file_free': drivers/gpu/drm/i915/selftests/mock_drm.c:54:1: error: the frame size of 1312 bytes is larger than 1280 bytes [-Werror=frame-larger-than=] It's also slightly dangerous to leave a reference to a stack object in the drm_file structure after leaving the stack frame. This changes the code to just allocate the object dynamically and release it when we are done with it. Fixes: 66d9cb5d805a ("drm/i915: Mock the GEM device for self-testing") Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/i915/selftests/mock_drm.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/selftests/mock_drm.c b/drivers/gpu/drm/i915/selftests/mock_drm.c index 113dec05c7dc..18514065c93d 100644 --- a/drivers/gpu/drm/i915/selftests/mock_drm.c +++ b/drivers/gpu/drm/i915/selftests/mock_drm.c @@ -32,15 +32,15 @@ static inline struct inode fake_inode(struct drm_i915_private *i915) struct drm_file *mock_file(struct drm_i915_private *i915) { struct inode inode = fake_inode(i915); - struct file filp = {}; + struct file *filp = kzalloc(sizeof(struct file), GFP_KERNEL); struct drm_file *file; int err; - err = drm_open(&inode, &filp); + err = drm_open(&inode, filp); if (unlikely(err)) return ERR_PTR(err); - file = filp.private_data; + file = filp->private_data; file->authenticated = true; return file; } @@ -48,7 +48,9 @@ struct drm_file *mock_file(struct drm_i915_private *i915) void mock_file_free(struct drm_i915_private *i915, struct drm_file *file) { struct inode inode = fake_inode(i915); - struct file filp = { .private_data = file }; + struct file *filp = file->filp; - drm_release(&inode, &filp); + drm_release(&inode, filp); + + kfree(filp); }