diff options
author | Jacopo Mondi <jacopo@jmondi.org> | 2019-04-16 15:31:45 +0200 |
---|---|---|
committer | Jacopo Mondi <jacopo@jmondi.org> | 2019-04-18 15:34:54 +0200 |
commit | da341a4dd146fe525d0e794e619c93dedd1a469c (patch) | |
tree | 0b80cde6741bd1efbe688561de2abc951084db05 /src | |
parent | 911bc4aa41c16eeeaf78ddb4c0a4958bdd19fb96 (diff) |
libcamera: camera: Don't call freeBuffer() on allocateBuffer() error
Do not assume the freeBuffer() function can handle allocateBuffer()
method failures, as error handling and clean up should be performed
by allocateBuffer() method itself.
Perform clean-up on allocations failures in the IPU3 pipeline handler,
now that freeBuffers() is not called anymore.
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/libcamera/camera.cpp | 1 | ||||
-rw-r--r-- | src/libcamera/pipeline/ipu3/ipu3.cpp | 16 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 21caa24b..2d0a8066 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -650,7 +650,6 @@ int Camera::allocateBuffers() int ret = pipe_->allocateBuffers(this, activeStreams_); if (ret) { LOG(Camera, Error) << "Failed to allocate buffers"; - freeBuffers(); return ret; } diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index f96e8763..924eb46c 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -314,6 +314,7 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera, Stream *stream = *streams.begin(); CIO2Device *cio2 = &data->cio2_; ImgUDevice *imgu = data->imgu_; + unsigned int bufferCount; int ret; /* Share buffers between CIO2 output and ImgU input. */ @@ -323,31 +324,36 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera, ret = imgu->importBuffers(pool); if (ret) - return ret; + goto error; /* Export ImgU output buffers to the stream's pool. */ ret = imgu->exportBuffers(&imgu->output_, &stream->bufferPool()); if (ret) - return ret; + goto error; /* * Reserve memory in viewfinder and stat output devices. Use the * same number of buffers as the ones requested for the output * stream. */ - unsigned int bufferCount = stream->bufferPool().count(); + bufferCount = stream->bufferPool().count(); imgu->viewfinder_.pool->createBuffers(bufferCount); ret = imgu->exportBuffers(&imgu->viewfinder_, imgu->viewfinder_.pool); if (ret) - return ret; + goto error; imgu->stat_.pool->createBuffers(bufferCount); ret = imgu->exportBuffers(&imgu->stat_, imgu->stat_.pool); if (ret) - return ret; + goto error; return 0; + +error: + freeBuffers(camera, streams); + + return ret; } int PipelineHandlerIPU3::freeBuffers(Camera *camera, |