Commit 8ef8678c authored by Dave Airlie's avatar Dave Airlie

drm/kms: protect against fb helper not being created.

If drivers don't init the fb helper on the connector, the cmdline
code won't work, but it shouldn't crash either.
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent adea4796
...@@ -279,16 +279,25 @@ static struct drm_display_mode *drm_has_preferred_mode(struct drm_connector *con ...@@ -279,16 +279,25 @@ static struct drm_display_mode *drm_has_preferred_mode(struct drm_connector *con
static bool drm_has_cmdline_mode(struct drm_connector *connector) static bool drm_has_cmdline_mode(struct drm_connector *connector)
{ {
struct drm_fb_helper_connector *fb_help_conn = connector->fb_helper_private; struct drm_fb_helper_connector *fb_help_conn = connector->fb_helper_private;
struct drm_fb_helper_cmdline_mode *cmdline_mode = &fb_help_conn->cmdline_mode; struct drm_fb_helper_cmdline_mode *cmdline_mode;
if (!fb_help_conn)
return false;
cmdline_mode = &fb_help_conn->cmdline_mode;
return cmdline_mode->specified; return cmdline_mode->specified;
} }
static struct drm_display_mode *drm_pick_cmdline_mode(struct drm_connector *connector, int width, int height) static struct drm_display_mode *drm_pick_cmdline_mode(struct drm_connector *connector, int width, int height)
{ {
struct drm_fb_helper_connector *fb_help_conn = connector->fb_helper_private; struct drm_fb_helper_connector *fb_help_conn = connector->fb_helper_private;
struct drm_fb_helper_cmdline_mode *cmdline_mode = &fb_help_conn->cmdline_mode; struct drm_fb_helper_cmdline_mode *cmdline_mode;
struct drm_display_mode *mode = NULL; struct drm_display_mode *mode = NULL;
if (!fb_help_conn)
return mode;
cmdline_mode = &fb_help_conn->cmdline_mode;
if (cmdline_mode->specified == false) if (cmdline_mode->specified == false)
return mode; return mode;
......
...@@ -90,8 +90,12 @@ static bool drm_fb_helper_connector_parse_command_line(struct drm_connector *con ...@@ -90,8 +90,12 @@ static bool drm_fb_helper_connector_parse_command_line(struct drm_connector *con
int i; int i;
enum drm_connector_force force = DRM_FORCE_UNSPECIFIED; enum drm_connector_force force = DRM_FORCE_UNSPECIFIED;
struct drm_fb_helper_connector *fb_help_conn = connector->fb_helper_private; struct drm_fb_helper_connector *fb_help_conn = connector->fb_helper_private;
struct drm_fb_helper_cmdline_mode *cmdline_mode = &fb_help_conn->cmdline_mode; struct drm_fb_helper_cmdline_mode *cmdline_mode;
if (!fb_help_conn)
return false;
cmdline_mode = &fb_help_conn->cmdline_mode;
if (!mode_option) if (!mode_option)
mode_option = fb_mode_option; mode_option = fb_mode_option;
...@@ -694,7 +698,13 @@ int drm_fb_helper_single_fb_probe(struct drm_device *dev, ...@@ -694,7 +698,13 @@ int drm_fb_helper_single_fb_probe(struct drm_device *dev,
/* first up get a count of crtcs now in use and new min/maxes width/heights */ /* first up get a count of crtcs now in use and new min/maxes width/heights */
list_for_each_entry(connector, &dev->mode_config.connector_list, head) { list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
struct drm_fb_helper_connector *fb_help_conn = connector->fb_helper_private; struct drm_fb_helper_connector *fb_help_conn = connector->fb_helper_private;
struct drm_fb_helper_cmdline_mode *cmdline_mode = &fb_help_conn->cmdline_mode;
struct drm_fb_helper_cmdline_mode *cmdline_mode;
if (!fb_help_conn)
continue;
cmdline_mode = &fb_help_conn->cmdline_mode;
if (cmdline_mode->bpp_specified) { if (cmdline_mode->bpp_specified) {
switch (cmdline_mode->bpp) { switch (cmdline_mode->bpp) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment