[PATCH] drm/amdgpu: Fix NULL pointer dereference

From: Grigory Vasilyev
Date: Fri Apr 08 2022 - 05:28:08 EST


The code below check for NULL, but is no check at this place, which is
potentially dangerous.

Signed-off-by: Grigory Vasilyev <h0tc0d3@xxxxxxxxx>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index d26810e7311d..c773a92dd4e5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -1017,8 +1017,10 @@ static int amdgpu_display_get_fb_info(const struct amdgpu_framebuffer *amdgpu_fb
int r;

if (!amdgpu_fb) {
- *tiling_flags = 0;
- *tmz_surface = false;
+ if (tiling_flags)
+ *tiling_flags = 0;
+ if (tmz_surface)
+ *tmz_surface = false;
return 0;
}

--
2.35.1