]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commit9d27e013fb328480bd2c48aba1eb58a36d12a73c
tree8867cf6af78235fc16af847908e2ab33325141e8
parentcf9343293ed1934d95a1ee440a97dc48c742613d
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: 7acade7b3a33 ("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