diff mbox

drm: Reject getfb for multi-plane framebuffers

Message ID 20180320225839.30905-1-daniels@collabora.com (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel Stone March 20, 2018, 10:58 p.m. UTC
getfb can only return a single plane, so reject attempts to use it with
multi-plane framebuffers.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reported-by: Daniel van Vugt <daniel.van.vugt@canonical.com>
Fixes: 308e5bcbdb10 ("drm: add an fb creation ioctl that takes a pixel format v5")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105518
---
 drivers/gpu/drm/drm_framebuffer.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Rob Clark March 21, 2018, 1:01 a.m. UTC | #1
On Tue, Mar 20, 2018 at 6:58 PM, Daniel Stone <daniels@collabora.com> wrote:
> getfb can only return a single plane, so reject attempts to use it with
> multi-plane framebuffers.
>

yeah, this seems like a pretty good idea,

Reviewed-by: Rob Clark <robdclark@gmail.com>

> Signed-off-by: Daniel Stone <daniels@collabora.com>
> Reported-by: Daniel van Vugt <daniel.van.vugt@canonical.com>
> Fixes: 308e5bcbdb10 ("drm: add an fb creation ioctl that takes a pixel format v5")
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105518
> ---
>  drivers/gpu/drm/drm_framebuffer.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
> index 7df025669067..ad67203de715 100644
> --- a/drivers/gpu/drm/drm_framebuffer.c
> +++ b/drivers/gpu/drm/drm_framebuffer.c
> @@ -462,6 +462,12 @@ int drm_mode_getfb(struct drm_device *dev,
>         if (!fb)
>                 return -ENOENT;
>
> +       /* Multi-planar framebuffers need getfb2. */
> +       if (fb->format->num_planes > 1) {
> +               ret = -EINVAL;
> +               goto out;
> +       }
> +
>         r->height = fb->height;
>         r->width = fb->width;
>         r->depth = fb->format->depth;
> @@ -485,6 +491,7 @@ int drm_mode_getfb(struct drm_device *dev,
>                 ret = -ENODEV;
>         }
>
> +out:
>         drm_framebuffer_put(fb);
>
>         return ret;
> --
> 2.16.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Daniel Vetter March 21, 2018, 8:27 a.m. UTC | #2
On Tue, Mar 20, 2018 at 09:01:11PM -0400, Rob Clark wrote:
> On Tue, Mar 20, 2018 at 6:58 PM, Daniel Stone <daniels@collabora.com> wrote:
> > getfb can only return a single plane, so reject attempts to use it with
> > multi-plane framebuffers.
> >
> 
> yeah, this seems like a pretty good idea,
> 
> Reviewed-by: Rob Clark <robdclark@gmail.com>
> 
> > Signed-off-by: Daniel Stone <daniels@collabora.com>
> > Reported-by: Daniel van Vugt <daniel.van.vugt@canonical.com>
> > Fixes: 308e5bcbdb10 ("drm: add an fb creation ioctl that takes a pixel format v5")
> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105518

Cc: stable@vger.kernel.org # v3.3+
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Please push to drm-misc-fixes and poke Gustavo to do a pull so it's not
lost.
-Daniel

> > ---
> >  drivers/gpu/drm/drm_framebuffer.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
> > index 7df025669067..ad67203de715 100644
> > --- a/drivers/gpu/drm/drm_framebuffer.c
> > +++ b/drivers/gpu/drm/drm_framebuffer.c
> > @@ -462,6 +462,12 @@ int drm_mode_getfb(struct drm_device *dev,
> >         if (!fb)
> >                 return -ENOENT;
> >
> > +       /* Multi-planar framebuffers need getfb2. */
> > +       if (fb->format->num_planes > 1) {
> > +               ret = -EINVAL;
> > +               goto out;
> > +       }
> > +
> >         r->height = fb->height;
> >         r->width = fb->width;
> >         r->depth = fb->format->depth;
> > @@ -485,6 +491,7 @@ int drm_mode_getfb(struct drm_device *dev,
> >                 ret = -ENODEV;
> >         }
> >
> > +out:
> >         drm_framebuffer_put(fb);
> >
> >         return ret;
> > --
> > 2.16.2
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Daniel Stone March 21, 2018, 12:04 p.m. UTC | #3
Hi,

On 21 March 2018 at 08:27, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Tue, Mar 20, 2018 at 09:01:11PM -0400, Rob Clark wrote:
>> On Tue, Mar 20, 2018 at 6:58 PM, Daniel Stone <daniels@collabora.com> wrote:
>> > getfb can only return a single plane, so reject attempts to use it with
>> > multi-plane framebuffers.
>> >
>>
>> yeah, this seems like a pretty good idea,
>>
>> Reviewed-by: Rob Clark <robdclark@gmail.com>
>>
>> > Signed-off-by: Daniel Stone <daniels@collabora.com>
>> > Reported-by: Daniel van Vugt <daniel.van.vugt@canonical.com>
>> > Fixes: 308e5bcbdb10 ("drm: add an fb creation ioctl that takes a pixel format v5")
>> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105518
>
> Cc: stable@vger.kernel.org # v3.3+
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
>
> Please push to drm-misc-fixes and poke Gustavo to do a pull so it's not
> lost.

Thanks both, I've pushed now. I suspect Gustavo is still on a plane
somewhere, but poked nevertheless.

Cheers,
aniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index 7df025669067..ad67203de715 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -462,6 +462,12 @@  int drm_mode_getfb(struct drm_device *dev,
 	if (!fb)
 		return -ENOENT;
 
+	/* Multi-planar framebuffers need getfb2. */
+	if (fb->format->num_planes > 1) {
+		ret = -EINVAL;
+		goto out;
+	}
+
 	r->height = fb->height;
 	r->width = fb->width;
 	r->depth = fb->format->depth;
@@ -485,6 +491,7 @@  int drm_mode_getfb(struct drm_device *dev,
 		ret = -ENODEV;
 	}
 
+out:
 	drm_framebuffer_put(fb);
 
 	return ret;