Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a2b2870

Browse files
AnnYugawaalexdeucher
authored andcommitted
drm/radeon: fix a possible null pointer dereference
In radeon_fp_native_mode(), the return value of drm_mode_duplicate() is assigned to mode, which will lead to a NULL pointer dereference on failure of drm_mode_duplicate(). Add a check to avoid npd. The failure status of drm_cvt_mode() on the other path is checked too. Signed-off-by: Gong Yuanjun <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 10784fe commit a2b2870

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/gpu/drm/radeon/radeon_connectors.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,8 @@ static struct drm_display_mode *radeon_fp_native_mode(struct drm_encoder *encode
473473
native_mode->vdisplay != 0 &&
474474
native_mode->clock != 0) {
475475
mode = drm_mode_duplicate(dev, native_mode);
476+
if (!mode)
477+
return NULL;
476478
mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER;
477479
drm_mode_set_name(mode);
478480

@@ -487,6 +489,8 @@ static struct drm_display_mode *radeon_fp_native_mode(struct drm_encoder *encode
487489
* simpler.
488490
*/
489491
mode = drm_cvt_mode(dev, native_mode->hdisplay, native_mode->vdisplay, 60, true, false, false);
492+
if (!mode)
493+
return NULL;
490494
mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER;
491495
DRM_DEBUG_KMS("Adding cvt approximation of native panel mode %s\n", mode->name);
492496
}

0 commit comments

Comments
 (0)