提交 4b674dd6 编写于 作者: S Steven Price 提交者: Liviu Dudau

drm/plane: Move range check for format_count earlier

While the check for format_count > 64 in __drm_universal_plane_init()
shouldn't be hit (it's a WARN_ON), in its current position it will then
leak the plane->format_types array and fail to call
drm_mode_object_unregister() leaking the modeset identifier. Move it to
the start of the function to avoid allocating those resources in the
first place.
Signed-off-by: NSteven Price <steven.price@arm.com>
Signed-off-by: NLiviu Dudau <liviu.dudau@arm.com>
Link: https://lore.kernel.org/dri-devel/20211203102815.38624-1-steven.price@arm.com/
上级 15342f93
...@@ -247,6 +247,13 @@ static int __drm_universal_plane_init(struct drm_device *dev, ...@@ -247,6 +247,13 @@ static int __drm_universal_plane_init(struct drm_device *dev,
if (WARN_ON(config->num_total_plane >= 32)) if (WARN_ON(config->num_total_plane >= 32))
return -EINVAL; return -EINVAL;
/*
* First driver to need more than 64 formats needs to fix this. Each
* format is encoded as a bit and the current code only supports a u64.
*/
if (WARN_ON(format_count > 64))
return -EINVAL;
WARN_ON(drm_drv_uses_atomic_modeset(dev) && WARN_ON(drm_drv_uses_atomic_modeset(dev) &&
(!funcs->atomic_destroy_state || (!funcs->atomic_destroy_state ||
!funcs->atomic_duplicate_state)); !funcs->atomic_duplicate_state));
...@@ -268,13 +275,6 @@ static int __drm_universal_plane_init(struct drm_device *dev, ...@@ -268,13 +275,6 @@ static int __drm_universal_plane_init(struct drm_device *dev,
return -ENOMEM; return -ENOMEM;
} }
/*
* First driver to need more than 64 formats needs to fix this. Each
* format is encoded as a bit and the current code only supports a u64.
*/
if (WARN_ON(format_count > 64))
return -EINVAL;
if (format_modifiers) { if (format_modifiers) {
const uint64_t *temp_modifiers = format_modifiers; const uint64_t *temp_modifiers = format_modifiers;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册