drm/rockchip: fix a couple off by one bugs
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 13 Jul 2016 10:15:04 +0000 (13:15 +0300)
committerMark Yao <mark.yao@rock-chips.com>
Tue, 19 Jul 2016 01:42:39 +0000 (09:42 +0800)
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>
drivers/gpu/drm/rockchip/rockchip_drm_drv.c

index 810042be40fd5f983048796d5ca105f0f0004185..a822d49a255ad898e57cafdd8a7d9be5aae68c5e 100644 (file)
@@ -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;