]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
drm/radeon: fix a possible null pointer dereference
authorMa Ke <make_ruc2021@163.com>
Wed, 11 Oct 2023 01:21:43 +0000 (09:21 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 13 Oct 2023 15:33:15 +0000 (11:33 -0400)
In radeon_tv_get_modes(), the return value of drm_cvt_mode()
is assigned to mode, which will lead to a NULL pointer
dereference on failure of drm_cvt_mode(). Add a check to
avoid null point dereference.

Signed-off-by: Ma Ke <make_ruc2021@163.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/radeon_connectors.c

index d2f02c3dfce29780dc1ddda5f718ade98b7ebe90..b84b58926106a47f08016b43f5db02576f3040e0 100644 (file)
@@ -1119,6 +1119,8 @@ static int radeon_tv_get_modes(struct drm_connector *connector)
        else {
                /* only 800x600 is supported right now on pre-avivo chips */
                tv_mode = drm_cvt_mode(dev, 800, 600, 60, false, false, false);
+               if (!tv_mode)
+                       return 0;
                tv_mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
                drm_mode_probed_add(connector, tv_mode);
        }