]> Git Repo - linux.git/commit
drm/amdgpu/virt: don't dereference undefined 'module' struct
authorArnd Bergmann <[email protected]>
Thu, 2 Nov 2017 11:25:39 +0000 (12:25 +0100)
committerAlex Deucher <[email protected]>
Fri, 3 Nov 2017 13:42:28 +0000 (09:42 -0400)
commite477e940dad1836c6f6d23353e424665b9316b6e
treeff281ae5c9913f1481f786ea677aeb06cdcec940
parentbf6eb600e5b835a96d676b2b9df603362a1e714c
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 <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
Reviewed-by: Harry Wentland <[email protected]>
Reviewed-By: Xiangliang Yu <[email protected]>
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
This page took 0.057108 seconds and 4 git commands to generate.