⬢ DragonFlyBSD Kernel Audit
DF-4436 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/drm/drm_plane.c
+++ b/sys/dev/drm/drm_plane.c
@@ -190,6 +190,9 @@
 		(!funcs->atomic_destroy_state ||
 		 !funcs->atomic_duplicate_state));
 
+	if (WARN_ON(format_count > 64))
+		return -EINVAL;
+
 	ret = drm_mode_object_add(dev, &plane->base, DRM_MODE_OBJECT_PLANE);
 	if (ret)
 		return ret;
@@ -207,12 +210,6 @@
 		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;