From patchwork Thu Nov 2 11:25:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10038541 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 9F7CA6032D for ; Thu, 2 Nov 2017 11:26:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9302628E45 for ; Thu, 2 Nov 2017 11:26:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87B5828E90; Thu, 2 Nov 2017 11:26:29 +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 2196F28E45 for ; Thu, 2 Nov 2017 11:26:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EDA0B6E0FC; Thu, 2 Nov 2017 11:26:27 +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.187]) by gabe.freedesktop.org (Postfix) with ESMTPS id C6EFA6E0FC for ; Thu, 2 Nov 2017 11:26:26 +0000 (UTC) Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue006 [212.227.15.129]) with ESMTPA (Nemesis) id 0LuFsJ-1dB94c1gPv-011ig3; Thu, 02 Nov 2017 12:26:21 +0100 From: Arnd Bergmann To: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= Subject: [PATCH] drm/amdgpu/virt: don't dereference undefined 'module' struct Date: Thu, 2 Nov 2017 12:25:39 +0100 Message-Id: <20171102112619.72157-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:eea/DMsO2FmUERzzFqdUZfs2lr6hbGTUKSM4ODOyTKMxgikW03u t9LjBRc6a8NmK/OClUriAOd5H6YwLlHQUA5eH/F8y7GZdP6CYksBIIjmdUw8QdULjiYUNYf wMhlxnckRsXLLg+zF5uyFHTRziUTNX2m/KwIHRAsin5EitqMm7j5MY97hObIa+jog2WKhMk AmujwYH43f97Fms53k7bQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:evOMXcWfqWg=:yebJohmO7EvtnBj6mYFzFa tV1Lea6e3+x/mI6gY/SlW6zuVDxvlOG58Y0Lo6OUuaz5MyHj0ZmkICqkVOjqOeGU4o61Xm2Ey nNBROFkijki4mudd6iizCekOJ1VuV608KV3ry4IBuO2LIZggJTQ5GvM7yhO8ck5ZqO6dXcLy2 Cth8HlfG9jlELc6CwiXxTqk7VDW8lAr+Y9dPp1kPmMlUM6heA0e2Yra3Ui7tIQU5qDBiEN7su yifevMgnjVmp0uByo8oEn2ocSTXtj7LENsTdLVE3+hT0xiJopwcs5n02zbyXXYCY/aZuMlDWR enKLtsX6zoOhPRiL9DXJKRy66HP882ZBVG3tSWwrJhaagFs1R0IGNkS5atZwBp4kwYUCaUwRx tH6YH//+JJpqctw86Z0icqNi1CiFPpt7+G5ahe+FRCeeY6n+4MdKhRpNHWoZcjrAqnSfTd0QB Kv2H/u1I2mZKPwigLs5TqkF0r1EayvxRfAxnJrcEZ+qCPjveSHnpT2UYzvPcy3dFy39yN3ycO 93muUq1XfI3t2lOP/Y1sp8s3jePbjjSrLqpg8j8O9xTxyIe6VsgN9y8T6XdniU4s87wkWGZ96 LRoRRlHZg/JRdVLD+J2BWOap4SwWiRGwFaXUERGZmecKZ+VsILhFDdvY72VVjXICy7gB/QrdP /avBqzWwh5x0NOt5ozay+WJo1T2jlV8ccMNznSJD7iHPE8JH+OJaY/iQoHS9DBJliRHjieBTl s6bHNrRXs3nQ66AdjfVLrWtioIrvN4OLFJnemw== Cc: Arnd Bergmann , David Airlie , Horace Chen , linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, Xiangliang Yu , dri-devel@lists.freedesktop.org, Monk Liu 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 Accessing the THIS_MODULE directly is only possible when modules are enabled, otherwise we get a build failure: drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c: In function 'amdgpu_virt_init_data_exchange': drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c:331:20: error: dereferencing pointer to incomplete type 'struct module' Further, THIS_MODULE is NULL when the driver is built-in, so the code would likely cause a NULL pointer dereference. This adds an #ifdef check to avoid the compile-time error, plus a NULL pointer check before dereferencing THIS_MODULE. It might be better to find a way to avoid using the module version altogether. Fixes: 2dc8f81e4f82 ("drm/amdgpu: SR-IOV data exchange between PF&VF") Signed-off-by: Arnd Bergmann Reviewed-by: Harry Wentland Reviewed-By: Xiangliang Yu --- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c index e97f80f86005..4e4a476593e8 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c @@ -328,9 +328,11 @@ void amdgpu_virt_init_data_exchange(struct amdgpu_device *adev) sizeof(amdgim_vf2pf_info)); AMDGPU_FW_VRAM_VF2PF_READ(adev, driver_version, &str); +#ifdef MODULE if (THIS_MODULE->version != NULL) strcpy(str, THIS_MODULE->version); else +#endif strcpy(str, "N/A"); AMDGPU_FW_VRAM_VF2PF_WRITE(adev, driver_cert, 0);