summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/msm/msm_drv.c
diff options
context:
space:
mode:
authorJordan Crouse <jcrouse@codeaurora.org>2017-03-07 09:50:28 -0700
committerRob Clark <robdclark@gmail.com>2017-04-08 06:59:32 -0400
commit36849cc361428b0b60c9065f854fe22bd55ce3ab (patch)
treeef8938ec8f7b62c0fbd786be8ed2c890901552f7 /drivers/gpu/drm/msm/msm_drv.c
parent2002c9c33259fd9147ebe949142f0b585bbfe869 (diff)
drm/msm: Don't increase priv->num_aspaces until we know that it fits
priv->num_aspaces is increased and then checked to see if it still fits in the priv->aspace array. If it doesn't, we warn and exit but priv->num_aspaces remains incremented. Don't incremement the count until we know that it fits in the array. Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Rob Clark <robdclark@gmail.com>
Diffstat (limited to 'drivers/gpu/drm/msm/msm_drv.c')
-rw-r--r--drivers/gpu/drm/msm/msm_drv.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 3f36c8d93122..87b5695d4034 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -55,14 +55,13 @@ int msm_register_address_space(struct drm_device *dev,
struct msm_gem_address_space *aspace)
{
struct msm_drm_private *priv = dev->dev_private;
- int idx = priv->num_aspaces++;
- if (WARN_ON(idx >= ARRAY_SIZE(priv->aspace)))
+ if (WARN_ON(priv->num_aspaces >= ARRAY_SIZE(priv->aspace)))
return -EINVAL;
- priv->aspace[idx] = aspace;
+ priv->aspace[priv->num_aspaces] = aspace;
- return idx;
+ return priv->num_aspaces++;
}
#ifdef CONFIG_DRM_MSM_REGISTER_LOGGING