Skip to content

Commit 7f3bbc0

Browse files
digetxmripard
authored andcommitted
drm/modes: Skip invalid cmdline mode
The named mode could be invalid and then cmdline parser misses to validate mode's dimensions, happily adding 0x0 mode as a valid mode. One case where this happens is NVIDIA Tegra devices that are using downstream bootloader which adds "video=tegrafb" to the kernel's cmdline and thus upstream Tegra DRM driver fails to probe because of the invalid mode. Fixes: 3aeeb13 ("drm/modes: Support modes names on the command line") Reviewed-by: Ville Syrjälä <[email protected]> Signed-off-by: Dmitry Osipenko <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 990dee3 commit 7f3bbc0

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

drivers/gpu/drm/drm_client_modeset.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ drm_connector_pick_cmdline_mode(struct drm_connector *connector)
180180

181181
create_mode:
182182
mode = drm_mode_create_from_cmdline_mode(connector->dev, cmdline_mode);
183-
list_add(&mode->head, &connector->modes);
183+
if (mode)
184+
list_add(&mode->head, &connector->modes);
184185

185186
return mode;
186187
}

drivers/gpu/drm/drm_modes.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ struct drm_display_mode *drm_cvt_mode(struct drm_device *dev, int hdisplay,
158158
int interlace;
159159
u64 tmp;
160160

161+
if (!hdisplay || !vdisplay)
162+
return NULL;
163+
161164
/* allocate the drm_display_mode structure. If failure, we will
162165
* return directly
163166
*/
@@ -392,6 +395,9 @@ drm_gtf_mode_complex(struct drm_device *dev, int hdisplay, int vdisplay,
392395
int hsync, hfront_porch, vodd_front_porch_lines;
393396
unsigned int tmp1, tmp2;
394397

398+
if (!hdisplay || !vdisplay)
399+
return NULL;
400+
395401
drm_mode = drm_mode_create(dev);
396402
if (!drm_mode)
397403
return NULL;

0 commit comments

Comments
 (0)