summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2022-06-10 01:00:54 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2022-06-10 01:00:54 +0000
commit9ff156b9971d5243baa3e6ad44cce8c2fd6275b8 (patch)
tree9f3769eb51915d450c7c2e935101e11c55df0901
parent5bd57e1eea7b07698df0f18fafaee9dcb2da42d4 (diff)
drm/plane: Move range check for format_count earlier
From Steven Price 978e3d023256bfaf34a0033d40c94e8a8e70cf3c in linux 5.15.y/5.15.46 4b674dd69701c2e22e8e7770c1706a69f3b17269 in mainline linux
-rw-r--r--sys/dev/pci/drm/drm_plane.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/sys/dev/pci/drm/drm_plane.c b/sys/dev/pci/drm/drm_plane.c
index 15e06db5b60..2a3feb831f1 100644
--- a/sys/dev/pci/drm/drm_plane.c
+++ b/sys/dev/pci/drm/drm_plane.c
@@ -249,6 +249,13 @@ static int __drm_universal_plane_init(struct drm_device *dev,
if (WARN_ON(config->num_total_plane >= 32))
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) &&
(!funcs->atomic_destroy_state ||
!funcs->atomic_duplicate_state));
@@ -270,13 +277,6 @@ static int __drm_universal_plane_init(struct drm_device *dev,
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) {
const uint64_t *temp_modifiers = format_modifiers;