This commit addresses a NULL dereference issue in the amdgpu_atif_handler function. The issue arises when event->device_class is NULL and is passed to the DRM_DEBUG_DRIVER macro, which attempts to print the NULL string with the %s format specifier. This constitutes undefined behavior. To resolve this, a conditional check is added to ensure that event->device_class is not NULL before it is passed to the DRM_DEBUG_DRIVER macro. If it is NULL, the string "NULL" is printed instead, thereby preventing the NULL dereference. Fixes the below: In function ‘amdgpu_atif_handler’, inlined from ‘amdgpu_acpi_event’ at drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c:1215:9: ./include/drm/drm_print.h:536:49: warning: ‘%s’ directive argument is null [-Wformat-overflow=] 536 | #define __drm_dbg(cat, fmt, ...) ___drm_dbg(NULL, cat, fmt, ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./include/drm/drm_print.h:582:9: note: in expansion of macro ‘__drm_dbg’ 582 | __drm_dbg(DRM_UT_DRIVER, fmt, ##__VA_ARGS__) | ^~~~~~~~~ drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c:452:9: note: in expansion of macro ‘DRM_DEBUG_DRIVER’ 452 | DRM_DEBUG_DRIVER("event, device_class = %s, type = %#x\n", | ^~~~~~~~~~~~~~~~ drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c: In function ‘amdgpu_acpi_event’: drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c:452:49: note: format string is defined here 452 | DRM_DEBUG_DRIVER("event, device_class = %s, type = %#x\n", | Cc: Alex Deucher <alexander.deucher@xxxxxxx> Cc: Christian König <christian.koenig@xxxxxxx> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@xxxxxxx> --- drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c index f85ace0384d2..27131ff30579 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c @@ -450,7 +450,7 @@ static int amdgpu_atif_handler(struct amdgpu_device *adev, int count; DRM_DEBUG_DRIVER("event, device_class = %s, type = %#x\n", - event->device_class, event->type); + event->device_class ? event->device_class : "NULL", event->type); if (strcmp(event->device_class, ACPI_VIDEO_CLASS) != 0) return NOTIFY_DONE; -- 2.34.1