{"id":15017,"url":"https://patchwork.libcamera.org/api/1.1/patches/15017/?format=json","web_url":"https://patchwork.libcamera.org/patch/15017/","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":"<20211203164619.1541033-5-hiroh@chromium.org>","date":"2021-12-03T16:46:16","name":"[libcamera-devel,4/7] libcamera: camera_manager: Protect cameras_ by mutex in cleanup()","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"049e3d552aacf147b2ac2d2e7a0fe4e8afc68966","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/1.1/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15017/mbox/","series":[{"id":2812,"url":"https://patchwork.libcamera.org/api/1.1/series/2812/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2812","date":"2021-12-03T16:46:12","name":"Apply clang thread safety annotation libcamera-core and v4l2","version":1,"mbox":"https://patchwork.libcamera.org/series/2812/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15017/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15017/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id E5929C3250\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  3 Dec 2021 16:46:35 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 94ABE60866;\n\tFri,  3 Dec 2021 17:46:35 +0100 (CET)","from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com\n\t[IPv6:2607:f8b0:4864:20::42a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7B7EE60832\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  3 Dec 2021 17:46:33 +0100 (CET)","by mail-pf1-x42a.google.com with SMTP id o4so3399354pfp.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 03 Dec 2021 08:46:33 -0800 (PST)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:cd78:3a5f:d792:6177])\n\tby smtp.gmail.com with ESMTPSA id\n\th18sm4123149pfh.172.2021.12.03.08.46.30\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 03 Dec 2021 08:46:31 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"imgryb0C\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=SOjwkxvaB3gTmgqq2Rgn4EIEGW+XBwNkwP7Cpqxju8U=;\n\tb=imgryb0C6UBerLH8Ofu2cPjRQOIPYp7tKpa+68QQwr0dUG92GNBtcHDKhfATMNCdoQ\n\tZXcKScHJ5V8q7DZ+gE6z/QVB9vV7oHgWBQHClyU1iu2RhY3ANGqcv0LLzqqQP2Gz4cQ4\n\txD20T5VQJoHnL+flfD0G0Wi8/avo2aBVdYlgc=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=SOjwkxvaB3gTmgqq2Rgn4EIEGW+XBwNkwP7Cpqxju8U=;\n\tb=FolTucwphtqp9EAVseH4r+lpRs71kCLyGNFm0JaVRqNLI5Anh73oQ7vQZ3i8gPlOEg\n\tkYdOwi3MONv7Y/ExEMwwgGnfMTebbLnQt7bTtqnr/9yDINvjFjC8EbzHn90zdhg4BxPS\n\tJ7LT2qYXGmiXr46veEWhSRqQHkMSd4qL/YM5e/90mtBjk1oGCoKODFqbCCJ2+KfSWiEm\n\tup4dFzWaZMfQ4HT4t+95lCmOt8DiS3c7eZZLaHTFxia6VR11wtJ9L+EgrAMIxeo48uSd\n\t8FOyoxBnQaIzQbXpR9Fsn72WWqyF41f/FKFEtJGsreR2LNaLb78sMlKrIZJFC52a8B0X\n\t6a4g==","X-Gm-Message-State":"AOAM530I5JgpjATZtO8Dpgay8xig2PdEB3jc000NEv9k/31S13xdod9i\n\tE1CWp4WP1BWuPk8j2v9qL7/Myg0MutB6Ig==","X-Google-Smtp-Source":"ABdhPJyis67JX/edsUfvdaj9esX/pPJI6VNKP8/w/iq3f97bKClA+v7K2GKPixlWMOJwwMhEP8KAnA==","X-Received":"by 2002:a63:6bc4:: with SMTP id\n\tg187mr5337417pgc.220.1638549991659; \n\tFri, 03 Dec 2021 08:46:31 -0800 (PST)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Sat,  4 Dec 2021 01:46:16 +0900","Message-Id":"<20211203164619.1541033-5-hiroh@chromium.org>","X-Mailer":"git-send-email 2.34.0.384.gca35af8252-goog","In-Reply-To":"<20211203164619.1541033-1-hiroh@chromium.org>","References":"<20211203164619.1541033-1-hiroh@chromium.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 4/7] libcamera: camera_manager: Protect\n\tcameras_ by mutex in cleanup()","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"This fixes the bug that camera_ is accessed without acquiring\nmutex_ in CameraManager::Private::cleanup().\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\n---\n src/libcamera/camera_manager.cpp | 3 +++\n 1 file changed, 3 insertions(+)","diff":"diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\nindex 70d73822..4492edc3 100644\n--- a/src/libcamera/camera_manager.cpp\n+++ b/src/libcamera/camera_manager.cpp\n@@ -178,7 +178,10 @@ void CameraManager::Private::cleanup()\n \t * process deletion requests from the thread's message queue as the event\n \t * loop is not in action here.\n \t */\n+\tmutex_.lock();\n \tcameras_.clear();\n+\tmutex_.unlock();\n+\n \tdispatchMessages(Message::Type::DeferredDelete);\n \n \tenumerator_.reset(nullptr);\n","prefixes":["libcamera-devel","4/7"]}