提交 ed181703 编写于 作者: O Oleg Drokin 提交者: Daniel Vetter

drm: fix a memleak on mutex failure path

Need to free just allocated ctx allocation if we cannot
get our config mutex.

This one has been flagged by kbuild bot all the way back in August,
but somehow nobody picked it up:
https://lists.01.org/pipermail/kbuild/2014-August/001691.html

In addition there is another failure path that leaks the same
ctx reference that is fixed.

Found with smatch.
Signed-off-by: NOleg Drokin <green@linuxhacker.ru>
CC: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: NJani Nikula <jani.nikula@intel.com>
Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
上级 3671c580
...@@ -80,8 +80,10 @@ int __drm_modeset_lock_all(struct drm_device *dev, ...@@ -80,8 +80,10 @@ int __drm_modeset_lock_all(struct drm_device *dev,
return -ENOMEM; return -ENOMEM;
if (trylock) { if (trylock) {
if (!mutex_trylock(&config->mutex)) if (!mutex_trylock(&config->mutex)) {
return -EBUSY; ret = -EBUSY;
goto out;
}
} else { } else {
mutex_lock(&config->mutex); mutex_lock(&config->mutex);
} }
...@@ -114,6 +116,8 @@ int __drm_modeset_lock_all(struct drm_device *dev, ...@@ -114,6 +116,8 @@ int __drm_modeset_lock_all(struct drm_device *dev,
goto retry; goto retry;
} }
out:
kfree(ctx);
return ret; return ret;
} }
EXPORT_SYMBOL(__drm_modeset_lock_all); EXPORT_SYMBOL(__drm_modeset_lock_all);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册