[1/4] drm/fb-helper: Do not assume drm_mode_create_from_cmdline_mode() can't fail

Submitted by Ville Syrjälä on June 7, 2019, 4:26 p.m.

Details

Message ID 20190607162611.23514-1-ville.syrjala@linux.intel.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Intel GFX

Browsing this patch as part of:
"Series without cover letter" rev 1 in Intel GFX
<< prev patch [1/4] next patch >>

Commit Message

Ville Syrjälä June 7, 2019, 4:26 p.m.
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

drm_mode_create_from_cmdline_mode() can return NULL, so the caller
should check for that.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_fb_helper.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index b9b7c06cbc4f..bdfa14cd7f6d 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -2205,7 +2205,9 @@  struct drm_display_mode *drm_pick_cmdline_mode(struct drm_fb_helper_connector *f
 create_mode:
 	mode = drm_mode_create_from_cmdline_mode(fb_helper_conn->connector->dev,
 						 cmdline_mode);
-	list_add(&mode->head, &fb_helper_conn->connector->modes);
+	if (mode)
+		list_add(&mode->head, &fb_helper_conn->connector->modes);
+
 	return mode;
 }
 EXPORT_SYMBOL(drm_pick_cmdline_mode);

Comments

On Fri, Jun 07, 2019 at 07:26:08PM +0300, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> drm_mode_create_from_cmdline_mode() can return NULL, so the caller
> should check for that.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Aside I noticed that we can drop a few EXPORT_SYMBOL here, I'll type a
patch.
-Daniel
> ---
>  drivers/gpu/drm/drm_fb_helper.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index b9b7c06cbc4f..bdfa14cd7f6d 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -2205,7 +2205,9 @@ struct drm_display_mode *drm_pick_cmdline_mode(struct drm_fb_helper_connector *f
>  create_mode:
>  	mode = drm_mode_create_from_cmdline_mode(fb_helper_conn->connector->dev,
>  						 cmdline_mode);
> -	list_add(&mode->head, &fb_helper_conn->connector->modes);
> +	if (mode)
> +		list_add(&mode->head, &fb_helper_conn->connector->modes);
> +
>  	return mode;
>  }
>  EXPORT_SYMBOL(drm_pick_cmdline_mode);
> -- 
> 2.21.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx