All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sylwester Nawrocki <snjw23@gmail.com>
To: Ezequiel Garcia <elezegarcia@gmail.com>
Cc: Hans Verkuil <hverkuil@xs4all.nl>,
	mchehab@redhat.com, linux-media@vger.kernel.org,
	hdegoede@redhat.com
Subject: Re: [RFC/PATCH] media: Add stk1160 new driver
Date: Sun, 27 May 2012 23:54:01 +0200	[thread overview]
Message-ID: <4FC2A279.2040404@gmail.com> (raw)
In-Reply-To: <CALF0-+VPkbZ8sUbPmxNT46J5S8X_jwRH3Wc4yX7DUHXyjKmbEg@mail.gmail.com>

Hi Ezequiel,

On 05/27/2012 11:32 PM, Ezequiel Garcia wrote:
>>>> +static int buffer_prepare(struct vb2_buffer *vb)
>>>> +{
>>>> +    struct stk1160 *dev = vb2_get_drv_priv(vb->vb2_queue);
>>>> +    struct stk1160_buffer *buf =
>>>> +                    container_of(vb, struct stk1160_buffer, vb);
>>>> +
>>>> +    /* If the device is disconnected, reject the buffer */
>>>> +    if (!dev->udev)
>>>> +            return -ENODEV;
>>>> +
>>>> +    buf->mem = vb2_plane_vaddr(vb, 0);
>>>> +    buf->length = vb2_plane_size(vb, 0);
>>
>> Where do you check if the buffer you get from vb2 has correct parameters
>> for your hardware (with current settings) to start writing data to it ?
>>
>> It seems that this driver supports just one pixel format and resolution,
>> but still would be good to do such checks in buf_prepare().
> 
> You mean I should check buf->length?

Yeah, you should validate the passed in vb2_buffer. Here is some example:
http://lxr.linux.no/#linux+v3.4/drivers/media/video/mx2_emmaprp.c#L715

IOW, you should compare value returned from vb2_plane_vaddr(vb, 0) during
streaming with value computed from pixel format and resolution -
configured with S_FMT. Rather than accepting any buffer passed to the driver
from user space.


Regards,
Sylwester

  reply	other threads:[~2012-05-27 21:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-26 17:50 [RFC/PATCH] media: Add stk1160 new driver Hans Verkuil
2012-05-26 18:38 ` Ezequiel Garcia
2012-05-26 19:19   ` Hans Verkuil
2012-05-26 19:31 ` Sylwester Nawrocki
2012-05-27 21:32   ` Ezequiel Garcia
2012-05-27 21:54     ` Sylwester Nawrocki [this message]
     [not found] <1338050460-5902-1-git-send-email-elezegarcia@gmail.com>
     [not found] ` <201205261905.25626.hverkuil@xs4all.nl>
2012-05-27 21:20   ` Ezequiel Garcia
2012-05-28 10:22     ` Hans Verkuil
2012-05-29 12:05       ` Ezequiel Garcia
2012-05-29 12:21         ` Hans Verkuil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FC2A279.2040404@gmail.com \
    --to=snjw23@gmail.com \
    --cc=elezegarcia@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.