{"id":654,"url":"https://patchwork.libcamera.org/api/1.1/patches/654/?format=json","web_url":"https://patchwork.libcamera.org/patch/654/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190228162913.6508-2-laurent.pinchart@ideasonboard.com>","date":"2019-02-28T16:29:04","name":"[libcamera-devel,01/10] libcamera: pipeline: Fix double release of media devices","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"4dc4a807d2ed7b7d24f3e8e70eb4bcf0757cc882","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/654/mbox/","series":[{"id":196,"url":"https://patchwork.libcamera.org/api/1.1/series/196/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=196","date":"2019-02-28T16:29:03","name":"Rework request completion handling","version":1,"mbox":"https://patchwork.libcamera.org/series/196/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/654/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/654/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 28A33610B6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Feb 2019 17:29:25 +0100 (CET)","from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B58CA67\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Feb 2019 17:29:24 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1551371364;\n\tbh=6EeDSKKsb49gVuJmphPuRuJ8UiJkOHnfVhKXfaGXb2k=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=uq5AUYYEdecQK+KiuQho0ljJbNkeYpksSDYGA8hAbutGWkP2vLofsCWzt2CHx4fTW\n\tI5eEhCuMsPDvV366pzGUdDWZ82PBvJxHmDWfMQVBKuOFBglUkFYzipxXaWTksQxQgx\n\tZaPSCsi96zIY8wvo8nq3r7gZUOlxYXuNJp1jsm48=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 28 Feb 2019 18:29:04 +0200","Message-Id":"<20190228162913.6508-2-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.19.2","In-Reply-To":"<20190228162913.6508-1-laurent.pinchart@ideasonboard.com>","References":"<20190228162913.6508-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 01/10] libcamera: pipeline: Fix double\n\trelease of media devices","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":"Thu, 28 Feb 2019 16:29:25 -0000"},"content":"Media devices are acquired in the match() function of pipeline handlers,\nand explicitly released if no match is found. The pipeline handler is\nthen deleted, which causes a second release of the media device in the\ndestructor. Fix this by removing the explicit release in the match()\nfunction.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/pipeline/ipu3/ipu3.cpp | 28 +++++++++++-----------------\n src/libcamera/pipeline/uvcvideo.cpp  |  1 -\n src/libcamera/pipeline/vimc.cpp      |  5 +----\n 3 files changed, 12 insertions(+), 22 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 9694d0ce51ab..cf5c28577393 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -278,19 +278,20 @@ bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator)\n \timgu_dm.add(\"ipu3-imgu 1 viewfinder\");\n \timgu_dm.add(\"ipu3-imgu 1 3a stat\");\n \n+\t/*\n+\t * It is safe to acquire both media devices at this point as\n+\t * DeviceEnumerator::search() skips the busy ones for us.\n+\t */\n \tcio2_ = enumerator->search(cio2_dm);\n \tif (!cio2_)\n \t\treturn false;\n \n+\tcio2_->acquire();\n+\n \timgu_ = enumerator->search(imgu_dm);\n \tif (!imgu_)\n \t\treturn false;\n \n-\t/*\n-\t * It is safe to acquire both media devices at this point as\n-\t * DeviceEnumerator::search() skips the busy ones for us.\n-\t */\n-\tcio2_->acquire();\n \timgu_->acquire();\n \n \t/*\n@@ -301,25 +302,18 @@ bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator)\n \t * not need to be changed after.\n \t */\n \tif (cio2_->open())\n-\t\tgoto error_release_mdev;\n+\t\treturn false;\n \n-\tif (cio2_->disableLinks())\n-\t\tgoto error_close_cio2;\n+\tif (cio2_->disableLinks()) {\n+\t\tcio2_->close();\n+\t\treturn false;\n+\t}\n \n \tregisterCameras();\n \n \tcio2_->close();\n \n \treturn true;\n-\n-error_close_cio2:\n-\tcio2_->close();\n-\n-error_release_mdev:\n-\tcio2_->release();\n-\timgu_->release();\n-\n-\treturn false;\n }\n \n /*\ndiff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\nindex b7b8ff109109..dd20bb085a29 100644\n--- a/src/libcamera/pipeline/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo.cpp\n@@ -167,7 +167,6 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)\n \t\tif (!video_)\n \t\t\tLOG(UVC, Error) << \"Could not find a default video device\";\n \n-\t\tmedia_->release();\n \t\treturn false;\n \t}\n \ndiff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\nindex 812777cffbb3..640fca5cb0e7 100644\n--- a/src/libcamera/pipeline/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc.cpp\n@@ -165,11 +165,8 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator)\n \tmedia_->acquire();\n \n \tvideo_ = new V4L2Device(media_->getEntityByName(\"Raw Capture 1\"));\n-\n-\tif (video_->open()) {\n-\t\tmedia_->release();\n+\tif (video_->open())\n \t\treturn false;\n-\t}\n \n \tstd::vector<Stream *> streams{ &stream_ };\n \tstd::shared_ptr<Camera> camera = Camera::create(this, \"VIMC Sensor B\",\n","prefixes":["libcamera-devel","01/10"]}