[V2 1/2] drm/amdgpu: validate if sw_init is defined or NULL
Sunil Khatri
sunil.khatri at amd.com
Wed Oct 9 09:19:59 UTC 2024
Before making a function call to sw_init, validate
the function pointer.
Signed-off-by: Sunil Khatri <sunil.khatri at amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 38a7423101f3..782f01ab39e2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2851,11 +2851,13 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
for (i = 0; i < adev->num_ip_blocks; i++) {
if (!adev->ip_blocks[i].status.valid)
continue;
- r = adev->ip_blocks[i].version->funcs->sw_init(&adev->ip_blocks[i]);
- if (r) {
- DRM_ERROR("sw_init of IP block <%s> failed %d\n",
+ if (adev->ip_blocks[i].version->funcs->sw_init) {
+ r = adev->ip_blocks[i].version->funcs->sw_init(&adev->ip_blocks[i]);
+ if (r) {
+ DRM_ERROR("sw_init of IP block <%s> failed %d\n",
adev->ip_blocks[i].version->funcs->name, r);
- goto init_failed;
+ goto init_failed;
+ }
}
adev->ip_blocks[i].status.sw = true;
--
2.34.1
More information about the amd-gfx
mailing list