libcamera: request: addBuffer(): Do fence check earlier
Check if the buffer has a fence before making any modifications because otherwise it is possible for `Request::addBuffer()` to return an error code while at the same time the buffer - for all intents and purposes - is added to the request. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
This commit is contained in:
parent
892e85e4e3
commit
32cc6717d2
1 changed files with 9 additions and 9 deletions
|
@ -475,6 +475,15 @@ int Request::addBuffer(const Stream *stream, FrameBuffer *buffer,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make sure the fence has been extracted from the buffer
|
||||
* to avoid waiting on a stale fence.
|
||||
*/
|
||||
if (buffer->_d()->fence()) {
|
||||
LOG(Request, Error) << "Can't add buffer that still references a fence";
|
||||
return -EEXIST;
|
||||
}
|
||||
|
||||
auto it = bufferMap_.find(stream);
|
||||
if (it != bufferMap_.end()) {
|
||||
LOG(Request, Error) << "FrameBuffer already set for stream";
|
||||
|
@ -485,15 +494,6 @@ int Request::addBuffer(const Stream *stream, FrameBuffer *buffer,
|
|||
_d()->pending_.insert(buffer);
|
||||
bufferMap_[stream] = buffer;
|
||||
|
||||
/*
|
||||
* Make sure the fence has been extracted from the buffer
|
||||
* to avoid waiting on a stale fence.
|
||||
*/
|
||||
if (buffer->_d()->fence()) {
|
||||
LOG(Request, Error) << "Can't add buffer that still references a fence";
|
||||
return -EEXIST;
|
||||
}
|
||||
|
||||
if (fence && fence->isValid())
|
||||
buffer->_d()->setFence(std::move(fence));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue