diff options
author | Thierry Reding <treding@nvidia.com> | 2015-12-15 06:20:49 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2015-12-15 07:35:25 -0500 |
commit | 4f250706211cdb949f7580d4fe4dd1fd646de693 (patch) | |
tree | e908950a001640db215e4a9962a908bbc614c5ad | |
parent | 50cbc132460d448fd24b561883f7cff21d77f147 (diff) |
drm/gma500: Sanity-check pipe index
If the DSI output isn't connected, then mdfld_dsi_encoder_get_pipe()
will return -1. The mdfld_dsi_dp_mode_set() function doesn't properly
check for this condition and causes the following compiler warnings:
CC drivers/gpu/drm/gma500/mdfld_dsi_dpi.o
drivers/gpu/drm/gma500/mdfld_dsi_dpi.c: In function ‘mdfld_dsi_dpi_mode_set’:
drivers/gpu/drm/gma500/mdfld_dsi_dpi.c:828:35: warning: array subscript is below array bounds [-Warray-bounds]
u32 pipeconf = dev_priv->pipeconf[pipe];
^
drivers/gpu/drm/gma500/mdfld_dsi_dpi.c:829:33: warning: array subscript is below array bounds [-Warray-bounds]
u32 dspcntr = dev_priv->dspcntr[pipe];
^
Fix this by checking for a valid pipe before indexing the pipeconf and
dspcntr arrays.
Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Reviewed-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1450178476-26284-2-git-send-email-boris.brezillon@free-electrons.com
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r-- | drivers/gpu/drm/gma500/mdfld_dsi_dpi.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c b/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c index 1a1acd3cb049..7cd87a0c2385 100644 --- a/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c +++ b/drivers/gpu/drm/gma500/mdfld_dsi_dpi.c | |||
@@ -821,14 +821,18 @@ void mdfld_dsi_dpi_mode_set(struct drm_encoder *encoder, | |||
821 | struct drm_device *dev = dsi_config->dev; | 821 | struct drm_device *dev = dsi_config->dev; |
822 | struct drm_psb_private *dev_priv = dev->dev_private; | 822 | struct drm_psb_private *dev_priv = dev->dev_private; |
823 | int pipe = mdfld_dsi_encoder_get_pipe(dsi_encoder); | 823 | int pipe = mdfld_dsi_encoder_get_pipe(dsi_encoder); |
824 | |||
825 | u32 pipeconf_reg = PIPEACONF; | 824 | u32 pipeconf_reg = PIPEACONF; |
826 | u32 dspcntr_reg = DSPACNTR; | 825 | u32 dspcntr_reg = DSPACNTR; |
826 | u32 pipeconf, dspcntr; | ||
827 | 827 | ||
828 | u32 pipeconf = dev_priv->pipeconf[pipe]; | ||
829 | u32 dspcntr = dev_priv->dspcntr[pipe]; | ||
830 | u32 mipi = MIPI_PORT_EN | PASS_FROM_SPHY_TO_AFE | SEL_FLOPPED_HSTX; | 828 | u32 mipi = MIPI_PORT_EN | PASS_FROM_SPHY_TO_AFE | SEL_FLOPPED_HSTX; |
831 | 829 | ||
830 | if (WARN_ON(pipe < 0)) | ||
831 | return; | ||
832 | |||
833 | pipeconf = dev_priv->pipeconf[pipe]; | ||
834 | dspcntr = dev_priv->dspcntr[pipe]; | ||
835 | |||
832 | if (pipe) { | 836 | if (pipe) { |
833 | pipeconf_reg = PIPECCONF; | 837 | pipeconf_reg = PIPECCONF; |
834 | dspcntr_reg = DSPCCNTR; | 838 | dspcntr_reg = DSPCCNTR; |