[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <BY2PR1201MB09353D47BD0360CDF2A548F1EB5D0@BY2PR1201MB0935.namprd12.prod.outlook.com>
Date: Fri, 3 Nov 2017 06:57:30 +0000
From: "Yu, Xiangliang" <Xiangliang.Yu@....com>
To: Arnd Bergmann <arnd@...db.de>,
"Deucher, Alexander" <Alexander.Deucher@....com>,
"Koenig, Christian" <Christian.Koenig@....com>
CC: David Airlie <airlied@...ux.ie>, "Liu, Monk" <Monk.Liu@....com>,
"Chen, Horace" <Horace.Chen@....com>,
"amd-gfx@...ts.freedesktop.org" <amd-gfx@...ts.freedesktop.org>,
"dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] drm/amdgpu/virt: don't dereference undefined 'module'
struct
Reviewed-By: Xiangliang Yu <Xiangliang.Yu@....com>
Thanks!
> -----Original Message-----
> From: Arnd Bergmann [mailto:arnd@...db.de]
> Sent: Thursday, November 02, 2017 7:26 PM
> To: Deucher, Alexander <Alexander.Deucher@....com>; Koenig, Christian
> <Christian.Koenig@....com>
> Cc: Arnd Bergmann <arnd@...db.de>; David Airlie <airlied@...ux.ie>; Liu,
> Monk <Monk.Liu@....com>; Yu, Xiangliang <Xiangliang.Yu@....com>;
> Chen, Horace <Horace.Chen@....com>; amd-gfx@...ts.freedesktop.org;
> dri-devel@...ts.freedesktop.org; linux-kernel@...r.kernel.org
> Subject: [PATCH] drm/amdgpu/virt: don't dereference undefined 'module'
> struct
>
> 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 <arnd@...db.de>
> ---
> 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);
> --
> 2.9.0
Powered by blists - more mailing lists