OSDN Git Service

drm/amdgpu: Fix a NULL pointer dereference in amdgpu_connector_lcd_native_mode()
authorZhou Qingyang <zhou1615@umn.edu>
Thu, 2 Dec 2021 16:17:36 +0000 (00:17 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 2 Dec 2021 17:43:31 +0000 (12:43 -0500)
commitb220110e4cd442156f36e1d9b4914bb9e87b0d00
tree8867cf6af78235fc16af847908e2ab33325141e8
parentbaf3f8f374062573c469631af03bf7fb1725896b
drm/amdgpu: Fix a NULL pointer dereference in amdgpu_connector_lcd_native_mode()

In amdgpu_connector_lcd_native_mode(), the return value of
drm_mode_duplicate() is assigned to mode, and there is a dereference
of it in amdgpu_connector_lcd_native_mode(), which will lead to a NULL
pointer dereference on failure of drm_mode_duplicate().

Fix this bug add a check of mode.

This bug was found by a static analyzer. The analysis employs
differential checking to identify inconsistent security operations
(e.g., checks or kfrees) between two code paths and confirms that the
inconsistent operations are not recovered in the current function or
the callers, so they constitute bugs.

Note that, as a bug found by static analysis, it can be a false
positive or hard to trigger. Multiple researchers have cross-reviewed
the bug.

Builds with CONFIG_DRM_AMDGPU=m show no new warnings, and
our static analyzer no longer warns about this code.

Fixes: d38ceaf99ed0 ("drm/amdgpu: add core driver (v4)")
Signed-off-by: Zhou Qingyang <zhou1615@umn.edu>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c