Patchwork [v2] drm/atomic: fix null pointer access to mode_fixup callback

login
register
mail settings
Submitter Inki Dae
Date Aug. 11, 2015, 12:23 p.m.
Message ID <1439295829-10395-1-git-send-email-inki.dae@samsung.com>
Download mbox | patch
Permalink /patch/6992091/
State New
Headers show

Comments

Inki Dae - Aug. 11, 2015, 12:23 p.m.
This patch fixes null pointer access incurred when
encoder driver didn't set its own mode_fixup callback.

mode_fixup callback shoudn't be called if the callback
of drm_encoder_helper_funcs is NULL.

Changelog v2:
- change it to else if

Signed-off-by: Inki Dae <inki.dae@samsung.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/drm_atomic_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Daniel Vetter - Aug. 11, 2015, 3:33 p.m.
On Tue, Aug 11, 2015 at 09:23:49PM +0900, Inki Dae wrote:
> This patch fixes null pointer access incurred when
> encoder driver didn't set its own mode_fixup callback.
> 
> mode_fixup callback shoudn't be called if the callback
> of drm_encoder_helper_funcs is NULL.
> 
> Changelog v2:
> - change it to else if
> 
> Signed-off-by: Inki Dae <inki.dae@samsung.com>
> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>

Applied to drm-misc, thanks.
-Daniel

> ---
>  drivers/gpu/drm/drm_atomic_helper.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index 5b59d5ad..c25bacb 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -298,7 +298,7 @@ mode_fixup(struct drm_atomic_state *state)
>  						 encoder->base.id, encoder->name);
>  				return ret;
>  			}
> -		} else {
> +		} else if (funcs->mode_fixup) {
>  			ret = funcs->mode_fixup(encoder, &crtc_state->mode,
>  						&crtc_state->adjusted_mode);
>  			if (!ret) {
> -- 
> 1.9.1
>

Patch

diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 5b59d5ad..c25bacb 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -298,7 +298,7 @@  mode_fixup(struct drm_atomic_state *state)
 						 encoder->base.id, encoder->name);
 				return ret;
 			}
-		} else {
+		} else if (funcs->mode_fixup) {
 			ret = funcs->mode_fixup(encoder, &crtc_state->mode,
 						&crtc_state->adjusted_mode);
 			if (!ret) {