libcamera: Put buffer back to V4L2BufferCache when VIDIOC_QBUF fails
The patch puts buffer back to V4L2BufferCache when VIDIOC_QBUF fails
in V4L2VideoDevice. This is to avoid cache leaks and causing assert.
Fixes: cadae67e45 ("libcamera: v4l2_videodevice: Add FrameBuffer interface")
Signed-off-by: Han-Lin Chen <hanlinchen@chromium.org>
Co-developed-by: Harvey Yang <chenghaoyang@chromium.org>
Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
committed by
Kieran Bingham
parent
1d65c02e71
commit
835c1bf35e
@@ -1682,11 +1682,15 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer)
|
||||
*/
|
||||
if (planes.size() < numV4l2Planes) {
|
||||
LOG(V4L2, Error) << "Frame buffer has too few planes";
|
||||
cache_->put(buf.index);
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (planes.size() != numV4l2Planes && !buffer->_d()->isContiguous()) {
|
||||
LOG(V4L2, Error) << "Device format requires contiguous buffer";
|
||||
cache_->put(buf.index);
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -1729,6 +1733,8 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer)
|
||||
if (i != planes.size() - 1 && bytesused != length) {
|
||||
LOG(V4L2, Error)
|
||||
<< "Holes in multi-planar buffer not supported";
|
||||
cache_->put(buf.index);
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
@@ -1778,6 +1784,8 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer)
|
||||
LOG(V4L2, Error)
|
||||
<< "Failed to queue buffer " << buf.index << ": "
|
||||
<< strerror(-ret);
|
||||
cache_->put(buf.index);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user