Patch Detail
Show a patch.
GET /api/patches/1026/?format=api
{ "id": 1026, "url": "https://patchwork.libcamera.org/api/patches/1026/?format=api", "web_url": "https://patchwork.libcamera.org/patch/1026/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20190417135858.23914-4-jacopo@jmondi.org>", "date": "2019-04-17T13:58:53", "name": "[libcamera-devel,v7,3/8] libcamera: camera: Don't call freeBuffer() on allocateBuffer() error", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "76b6b64ff9e9a827a5f52e0b68313a8552315b04", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/1026/mbox/", "series": [ { "id": 254, "url": "https://patchwork.libcamera.org/api/series/254/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=254", "date": "2019-04-17T13:58:50", "name": "libcamera: Framework changes to prepare for multiple streams support", "version": 7, "mbox": "https://patchwork.libcamera.org/series/254/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/1026/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/1026/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net\n\t[217.70.183.194])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1694E60DC3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 17 Apr 2019 15:58:18 +0200 (CEST)", "from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 9E53440017;\n\tWed, 17 Apr 2019 13:58:17 +0000 (UTC)" ], "X-Originating-IP": "2.224.242.101", "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 17 Apr 2019 15:58:53 +0200", "Message-Id": "<20190417135858.23914-4-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.21.0", "In-Reply-To": "<20190417135858.23914-1-jacopo@jmondi.org>", "References": "<20190417135858.23914-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v7 3/8] libcamera: camera: Don't call\n\tfreeBuffer() on allocateBuffer() error", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.23", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "X-List-Received-Date": "Wed, 17 Apr 2019 13:58:18 -0000" }, "content": "Do not assume the freeBuffer() function can handle allocateBuffer()\nmethod failures, as error handling and clean up should be performed\nby allocateBuffer() method itself.\n\nPerform clean-up on allocations failures in the IPU3 pipeline handler,\nnow that freeBuffers() is not called anymore.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/camera.cpp | 1 -\n src/libcamera/pipeline/ipu3/ipu3.cpp | 19 ++++++++++++++-----\n 2 files changed, 14 insertions(+), 6 deletions(-)", "diff": "diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 21caa24b90b5..2d0a80664214 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -650,7 +650,6 @@ int Camera::allocateBuffers()\n \tint ret = pipe_->allocateBuffers(this, activeStreams_);\n \tif (ret) {\n \t\tLOG(Camera, Error) << \"Failed to allocate buffers\";\n-\t\tfreeBuffers();\n \t\treturn ret;\n \t}\n \ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex f96e8763bce9..6e093fc22259 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -314,6 +314,7 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera,\n \tStream *stream = *streams.begin();\n \tCIO2Device *cio2 = &data->cio2_;\n \tImgUDevice *imgu = data->imgu_;\n+\tunsigned int bufferCount;\n \tint ret;\n \n \t/* Share buffers between CIO2 output and ImgU input. */\n@@ -323,31 +324,39 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera,\n \n \tret = imgu->importBuffers(pool);\n \tif (ret)\n-\t\treturn ret;\n+\t\tgoto error_free_cio2;\n \n \t/* Export ImgU output buffers to the stream's pool. */\n \tret = imgu->exportBuffers(&imgu->output_, &stream->bufferPool());\n \tif (ret)\n-\t\treturn ret;\n+\t\tgoto error_free_imgu;\n \n \t/*\n \t * Reserve memory in viewfinder and stat output devices. Use the\n \t * same number of buffers as the ones requested for the output\n \t * stream.\n \t */\n-\tunsigned int bufferCount = stream->bufferPool().count();\n+\tbufferCount = stream->bufferPool().count();\n \n \timgu->viewfinder_.pool->createBuffers(bufferCount);\n \tret = imgu->exportBuffers(&imgu->viewfinder_, imgu->viewfinder_.pool);\n \tif (ret)\n-\t\treturn ret;\n+\t\tgoto error_free_imgu;\n \n \timgu->stat_.pool->createBuffers(bufferCount);\n \tret = imgu->exportBuffers(&imgu->stat_, imgu->stat_.pool);\n \tif (ret)\n-\t\treturn ret;\n+\t\tgoto error_free_imgu;\n \n \treturn 0;\n+\n+error_free_imgu:\n+\timgu->freeBuffers();\n+\n+error_free_cio2:\n+\tcio2->freeBuffers();\n+\n+\treturn ret;\n }\n \n int PipelineHandlerIPU3::freeBuffers(Camera *camera,\n", "prefixes": [ "libcamera-devel", "v7", "3/8" ] }