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
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to