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: 117793 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2037166qgn; Thu, 2 Nov 2017 04:26:32 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Qpry9cZHxWrEF5uj4d9V1oArxFhWBlQlPtFgvIugurx66C/OR+OY9Mxy6LvqA5EI3kYKb7 X-Received: by 10.98.9.207 with SMTP id 76mr3471650pfj.70.1509621992068; Thu, 02 Nov 2017 04:26:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509621992; cv=none; d=google.com; s=arc-20160816; b=fQ9uQ6+KMIZf2TLWyhXJtiiggftxXJ90fIsijUgZN38eUeuWUFsJ44BptkOhbKNhPV vtLyN29zEOVYIjbyX2PWRCi71LXFm0f2V4wHQ7qvx0zgg5ee3LS7CegQfdcCi51nQ1LK yZX/1hpPiT+M/UOqP/BKnfhPWYPK2vlWTJjijbMyyeeien3nzu1wE1gtGbPhQ6HRxMlp YRdQ8U77CHkR1DaD6Xjq7QdLUB4RySYc/8FnA8+cmCIlNjsHnGIrUvWQZcup6SL7jiSN hTTcJcttigxjvU/xw1jIUXQI/8D6FeglL90NC0zKMj4A//uYQHQVihFc74tcGUtfR2lC BoiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=hsHWg1Q3Dxh0lkD+TTj2JffNOaCXF1UGMjoZ0Oe9Q80=; b=yyZedivhbIa97YddfDQ1AptWPKyw5m0TMdwR/gRPcz7kd0T/pXRBxM3jJBNFXObRmC vd7P/l+Ab5ee8+oTq7hRYE983OQFPGtoo386b92omz7rRQohPQXnjKxugax9xP99282j DK72ZkLZiUn/qIuoNK1GEYwO8rO/P/Lbu2QrgRzu/DzkX1/jj0fMFH9YeYygh4B7dMEv VxgBNkMDNXoO+mj9Av1AZByIOmOBWBUP4TlDtoOD9jWciiJ+dYv0CcbDv1UzeoPGbrh+ OU8nxQbEleA31dURkThqxgXkCM3bQXJI1tW184ScbNXlUqzMAiEbomx0eozaZnQFh2da JlLg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 97si2193560pld.158.2017.11.02.04.26.31; Thu, 02 Nov 2017 04:26:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752266AbdKBL0a (ORCPT + 26 others); Thu, 2 Nov 2017 07:26:30 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:55022 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751370AbdKBL02 (ORCPT ); Thu, 2 Nov 2017 07:26:28 -0400 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_K=C3=B6n?= =?utf-8?q?ig?= Cc: Arnd Bergmann , David Airlie , Monk Liu , Xiangliang Yu , Horace Chen , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org 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== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.9.0 Reviewed-by: Harry Wentland Reviewed-By: Xiangliang Yu 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);