提交 36849cc3 编写于 作者: J Jordan Crouse 提交者: Rob Clark

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: NJordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: NRob Clark <robdclark@gmail.com>
上级 2002c9c3
...@@ -55,14 +55,13 @@ int msm_register_address_space(struct drm_device *dev, ...@@ -55,14 +55,13 @@ int msm_register_address_space(struct drm_device *dev,
struct msm_gem_address_space *aspace) struct msm_gem_address_space *aspace)
{ {
struct msm_drm_private *priv = dev->dev_private; 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; return -EINVAL;
priv->aspace[idx] = aspace; priv->aspace[priv->num_aspaces] = aspace;
return idx; return priv->num_aspaces++;
} }
#ifdef CONFIG_DRM_MSM_REGISTER_LOGGING #ifdef CONFIG_DRM_MSM_REGISTER_LOGGING
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册