drm: plane: Check that the fb pixel format is supported by the plane
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 14 Dec 2011 22:11:50 +0000 (00:11 +0200)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 3 Jul 2012 09:28:59 +0000 (12:28 +0300)
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Pauli Nieminen <pauli.nieminen@linux.intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
drivers/gpu/drm/drm_crtc.c

index d555d94..9f47dfc 100644 (file)
@@ -1660,6 +1660,7 @@ int drm_mode_setplane(struct drm_device *dev, void *data,
        struct drm_framebuffer *fb;
        int ret = 0;
        unsigned int fb_width, fb_height;
+       int i;
 
        if (!drm_core_check_feature(dev, DRIVER_MODESET))
                return -EINVAL;
@@ -1708,6 +1709,16 @@ int drm_mode_setplane(struct drm_device *dev, void *data,
        }
        fb = obj_to_fb(obj);
 
+       /* Check whether this plane supports the fb pixel format. */
+       for (i = 0; i < plane->format_count; i++)
+               if (fb->pixel_format == plane->format_types[i])
+                       break;
+       if (i == plane->format_count) {
+               DRM_DEBUG_KMS("Invalid pixel format %x\n", fb->pixel_format);
+               ret = -EINVAL;
+               goto out;
+       }
+
        fb_width = fb->width << 16;
        fb_height = fb->height << 16;