diff mbox

drm/rockchip: fix a couple off by one bugs

Message ID 20160713101504.GJ29468@mwanda (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter July 13, 2016, 10:15 a.m. UTC
The priv->crtc_funcs[] array has ROCKCHIP_MAX_CRTC elements so > should
be >= here.

Fixes: 2048e3286f34 ('drm: rockchip: Add basic drm driver')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Comments

Sean Paul July 13, 2016, 3:38 p.m. UTC | #1
On Wed, Jul 13, 2016 at 3:15 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> The priv->crtc_funcs[] array has ROCKCHIP_MAX_CRTC elements so > should
> be >= here.
>
> Fixes: 2048e3286f34 ('drm: rockchip: Add basic drm driver')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>

Reviewed-by: Sean Paul <seanpaul@chromium.org>

> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> index 7fd20c0..37ca427 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> @@ -79,7 +79,7 @@ int rockchip_register_crtc_funcs(struct drm_crtc *crtc,
>         int pipe = drm_crtc_index(crtc);
>         struct rockchip_drm_private *priv = crtc->dev->dev_private;
>
> -       if (pipe > ROCKCHIP_MAX_CRTC)
> +       if (pipe >= ROCKCHIP_MAX_CRTC)
>                 return -EINVAL;
>
>         priv->crtc_funcs[pipe] = crtc_funcs;
> @@ -92,7 +92,7 @@ void rockchip_unregister_crtc_funcs(struct drm_crtc *crtc)
>         int pipe = drm_crtc_index(crtc);
>         struct rockchip_drm_private *priv = crtc->dev->dev_private;
>
> -       if (pipe > ROCKCHIP_MAX_CRTC)
> +       if (pipe >= ROCKCHIP_MAX_CRTC)
>                 return;
>
>         priv->crtc_funcs[pipe] = NULL;
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
yao mark July 14, 2016, 2:22 a.m. UTC | #2
On 2016年07月13日 18:15, Dan Carpenter wrote:
> The priv->crtc_funcs[] array has ROCKCHIP_MAX_CRTC elements so > should
> be >= here.
>
> Fixes: 2048e3286f34 ('drm: rockchip: Add basic drm driver')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks for the fix, applied to my drm-fixes.

> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> index 7fd20c0..37ca427 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> @@ -79,7 +79,7 @@ int rockchip_register_crtc_funcs(struct drm_crtc *crtc,
>   	int pipe = drm_crtc_index(crtc);
>   	struct rockchip_drm_private *priv = crtc->dev->dev_private;
>   
> -	if (pipe > ROCKCHIP_MAX_CRTC)
> +	if (pipe >= ROCKCHIP_MAX_CRTC)
>   		return -EINVAL;
>   
>   	priv->crtc_funcs[pipe] = crtc_funcs;
> @@ -92,7 +92,7 @@ void rockchip_unregister_crtc_funcs(struct drm_crtc *crtc)
>   	int pipe = drm_crtc_index(crtc);
>   	struct rockchip_drm_private *priv = crtc->dev->dev_private;
>   
> -	if (pipe > ROCKCHIP_MAX_CRTC)
> +	if (pipe >= ROCKCHIP_MAX_CRTC)
>   		return;
>   
>   	priv->crtc_funcs[pipe] = NULL;
>
>
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index 7fd20c0..37ca427 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -79,7 +79,7 @@  int rockchip_register_crtc_funcs(struct drm_crtc *crtc,
 	int pipe = drm_crtc_index(crtc);
 	struct rockchip_drm_private *priv = crtc->dev->dev_private;
 
-	if (pipe > ROCKCHIP_MAX_CRTC)
+	if (pipe >= ROCKCHIP_MAX_CRTC)
 		return -EINVAL;
 
 	priv->crtc_funcs[pipe] = crtc_funcs;
@@ -92,7 +92,7 @@  void rockchip_unregister_crtc_funcs(struct drm_crtc *crtc)
 	int pipe = drm_crtc_index(crtc);
 	struct rockchip_drm_private *priv = crtc->dev->dev_private;
 
-	if (pipe > ROCKCHIP_MAX_CRTC)
+	if (pipe >= ROCKCHIP_MAX_CRTC)
 		return;
 
 	priv->crtc_funcs[pipe] = NULL;