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

login
register
mail settings
Submitter Inki Dae
Date Aug. 11, 2015, noon
Message ID <1439294427-9723-1-git-send-email-inki.dae@samsung.com>
Download mbox | patch
Permalink /patch/6991951/
State New
Headers show

Comments

Inki Dae - Aug. 11, 2015, noon
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.

Signed-off-by: Inki Dae <inki.dae@samsung.com>
---
 drivers/gpu/drm/drm_atomic_helper.c | 3 +++
 1 file changed, 3 insertions(+)
Maarten Lankhorst - Aug. 11, 2015, 12:15 p.m.
Op 11-08-15 om 14:00 schreef Inki Dae:
> 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.
>
> Signed-off-by: Inki Dae <inki.dae@samsung.com>
> ---
>  drivers/gpu/drm/drm_atomic_helper.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index 5b59d5ad..b69469c 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -299,6 +299,9 @@ mode_fixup(struct drm_atomic_state *state)
>  				return ret;
>  			}
>  		} else {
> +			if (!funcs->mode_fixup)
> +				continue;
Change it to } else if (funcs->mode_fixup) { ?

Reviewed-By: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>


>  			ret = funcs->mode_fixup(encoder, &crtc_state->mode,
>  						&crtc_state->adjusted_mode);
>  			if (!ret) {

Patch

diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 5b59d5ad..b69469c 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -299,6 +299,9 @@  mode_fixup(struct drm_atomic_state *state)
 				return ret;
 			}
 		} else {
+			if (!funcs->mode_fixup)
+				continue;
+
 			ret = funcs->mode_fixup(encoder, &crtc_state->mode,
 						&crtc_state->adjusted_mode);
 			if (!ret) {