Skip to content

Commit cd90511

Browse files
Ma Kealexdeucher
authored andcommitted
drm/amdgpu/vkms: fix a possible null pointer dereference
In amdgpu_vkms_conn_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 pointer dereference. Signed-off-by: Ma Ke <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 49c775b commit cd90511

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ static int amdgpu_vkms_conn_get_modes(struct drm_connector *connector)
239239

240240
for (i = 0; i < ARRAY_SIZE(common_modes); i++) {
241241
mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h, 60, false, false, false);
242+
if (!mode)
243+
continue;
242244
drm_mode_probed_add(connector, mode);
243245
}
244246

0 commit comments

Comments
 (0)