drm: plane: Check that the fb pixel format is supported by the plane
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Mon, 19 Dec 2011 22:06:47 +0000 (00:06 +0200)
committerDave Airlie <airlied@redhat.com>
Tue, 20 Dec 2011 10:05:32 +0000 (10:05 +0000)
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/drm_crtc.c

index 80cfe1cbeb99302363a475f93c4de1ad2e835975..66a165dac5c4461e0082a555dcc84b53f3cd0c2d 100644 (file)
@@ -1662,6 +1662,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;
@@ -1710,6 +1711,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 0x%08x\n", fb->pixel_format);
+               ret = -EINVAL;
+               goto out;
+       }
+
        fb_width = fb->width << 16;
        fb_height = fb->height << 16;