forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/drivers/gpu/drm/drm_property.c
....@@ -21,13 +21,15 @@
2121 */
2222
2323 #include <linux/export.h>
24
-#include <drm/drmP.h>
24
+#include <linux/uaccess.h>
25
+
26
+#include <drm/drm_crtc.h>
27
+#include <drm/drm_drv.h>
28
+#include <drm/drm_file.h>
29
+#include <drm/drm_framebuffer.h>
2530 #include <drm/drm_property.h>
2631
2732 #include "drm_crtc_internal.h"
28
-
29
-#define MAX_BLOB_PROP_SIZE (PAGE_SIZE * 30)
30
-#define MAX_BLOB_PROP_COUNT 250
3133
3234 /**
3335 * DOC: overview
....@@ -467,7 +469,7 @@
467469 uint64_t __user *values_ptr;
468470
469471 if (!drm_core_check_feature(dev, DRIVER_MODESET))
470
- return -EINVAL;
472
+ return -EOPNOTSUPP;
471473
472474 property = drm_property_find(dev, file_priv, out_resp->prop_id);
473475 if (!property)
....@@ -559,8 +561,7 @@
559561 struct drm_property_blob *blob;
560562 int ret;
561563
562
- if (!length || length > MAX_BLOB_PROP_SIZE -
563
- sizeof(struct drm_property_blob))
564
+ if (!length || length > INT_MAX - sizeof(struct drm_property_blob))
564565 return ERR_PTR(-EINVAL);
565566
566567 blob = kvzalloc(sizeof(struct drm_property_blob)+length, GFP_KERNEL);
....@@ -761,7 +762,7 @@
761762 int ret = 0;
762763
763764 if (!drm_core_check_feature(dev, DRIVER_MODESET))
764
- return -EINVAL;
765
+ return -EOPNOTSUPP;
765766
766767 blob = drm_property_lookup_blob(dev, out_resp->blob_id);
767768 if (!blob)
....@@ -786,19 +787,10 @@
786787 void *data, struct drm_file *file_priv)
787788 {
788789 struct drm_mode_create_blob *out_resp = data;
789
- struct drm_property_blob *blob, *bt;
790
+ struct drm_property_blob *blob;
790791 int ret = 0;
791
- u32 count = 0;
792792
793793 if (!drm_core_check_feature(dev, DRIVER_MODESET))
794
- return -EINVAL;
795
-
796
- mutex_lock(&dev->mode_config.blob_lock);
797
- list_for_each_entry(bt, &file_priv->blobs, head_file)
798
- count++;
799
- mutex_unlock(&dev->mode_config.blob_lock);
800
-
801
- if (count >= MAX_BLOB_PROP_COUNT)
802794 return -EOPNOTSUPP;
803795
804796 blob = drm_property_create_blob(dev, out_resp->length, NULL);
....@@ -836,7 +828,7 @@
836828 int ret = 0;
837829
838830 if (!drm_core_check_feature(dev, DRIVER_MODESET))
839
- return -EINVAL;
831
+ return -EOPNOTSUPP;
840832
841833 blob = drm_property_lookup_blob(dev, out_resp->blob_id);
842834 if (!blob)
....@@ -879,7 +871,7 @@
879871 * value doesn't become invalid part way through the property update due to
880872 * race). The value returned by reference via 'obj' should be passed back
881873 * to drm_property_change_valid_put() after the property is set (and the
882
- * object to which the property is attached has a chance to take it's own
874
+ * object to which the property is attached has a chance to take its own
883875 * reference).
884876 */
885877 bool drm_property_change_valid_get(struct drm_property *property,