[FFmpeg-devel] [PATCH] libavdevice/v4l2: fix of crash caused by assert

Michael Niedermayer michaelni at gmx.at
Tue Sep 2 02:07:50 CEST 2014


On Mon, Sep 01, 2014 at 11:00:14PM +0200, Giorgio Vazzana wrote:
> 2014-09-01 22:46 GMT+02:00 Reimar Döffinger <Reimar.Doeffinger at gmx.de>:
> > On Mon, Sep 01, 2014 at 10:33:15PM +0200, Giorgio Vazzana wrote:
> >> +static int enqueue_buffer(struct video_data *s, struct v4l2_buffer *buf)
> >> +{
> >> +    int res = 0;
> >> +
> >> +    if (v4l2_ioctl(s->fd, VIDIOC_QBUF, buf) < 0) {
> >> +        res = AVERROR(errno);
> >> +        av_log(NULL, AV_LOG_ERROR, "ioctl(VIDIOC_QBUF): %s\n", av_err2str(res));
> >> +    } else {
> >> +        avpriv_atomic_int_add_and_fetch(&s->buffers_queued, 1);
> >> +    }
> >> +
> >> +    return res;
> >
> > Nit: I'd prefer something simpler that avoids cluttering the normal path
> > because of error handling like:
> >
> >> +    if (v4l2_ioctl(s->fd, VIDIOC_QBUF, buf) < 0) {
> >> +        av_log(NULL, AV_LOG_ERROR, "ioctl(VIDIOC_QBUF): %s\n", av_err2str(res));
> >> +        return AVERROR(errno);
> 
> If we call av_log(), errno is not guaranteed to be the same after the
> call. Also, av_err2str() needs AVERROR(errno).
> 
> >> +    }
> >> +    avpriv_atomic_int_add_and_fetch(&s->buffers_queued, 1);
> >> +    return 0;
> >
> >
> >
> >
> >>  static void mmap_release_buffer(void *opaque, uint8_t *data)
> >
> > I haven't checked, but I suspect this function could be made simpler
> > and more likely to not re-introduce these bugs by using for the
> > error paths goto.
> > Admittedly that doesn't belong in this patch anyway though.
> 
> OK, we'll fix this in another patch then.

should i apply the previous patch or wait ?

also if you want, you can add yourself to the v4l2 maintainers in the
MAINTAINERs file, as you seem to be doing a signifiant part of its
maintaince already

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140902/ed119ff8/attachment.asc>


More information about the ffmpeg-devel mailing list