From patchwork Fri Dec 3 16:46:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 15017 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id E5929C3250 for ; Fri, 3 Dec 2021 16:46:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 94ABE60866; Fri, 3 Dec 2021 17:46:35 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="imgryb0C"; dkim-atps=neutral Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7B7EE60832 for ; Fri, 3 Dec 2021 17:46:33 +0100 (CET) Received: by mail-pf1-x42a.google.com with SMTP id o4so3399354pfp.13 for ; Fri, 03 Dec 2021 08:46:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SOjwkxvaB3gTmgqq2Rgn4EIEGW+XBwNkwP7Cpqxju8U=; b=imgryb0C6UBerLH8Ofu2cPjRQOIPYp7tKpa+68QQwr0dUG92GNBtcHDKhfATMNCdoQ ZXcKScHJ5V8q7DZ+gE6z/QVB9vV7oHgWBQHClyU1iu2RhY3ANGqcv0LLzqqQP2Gz4cQ4 xD20T5VQJoHnL+flfD0G0Wi8/avo2aBVdYlgc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SOjwkxvaB3gTmgqq2Rgn4EIEGW+XBwNkwP7Cpqxju8U=; b=FolTucwphtqp9EAVseH4r+lpRs71kCLyGNFm0JaVRqNLI5Anh73oQ7vQZ3i8gPlOEg kYdOwi3MONv7Y/ExEMwwgGnfMTebbLnQt7bTtqnr/9yDINvjFjC8EbzHn90zdhg4BxPS J7LT2qYXGmiXr46veEWhSRqQHkMSd4qL/YM5e/90mtBjk1oGCoKODFqbCCJ2+KfSWiEm up4dFzWaZMfQ4HT4t+95lCmOt8DiS3c7eZZLaHTFxia6VR11wtJ9L+EgrAMIxeo48uSd 8FOyoxBnQaIzQbXpR9Fsn72WWqyF41f/FKFEtJGsreR2LNaLb78sMlKrIZJFC52a8B0X 6a4g== X-Gm-Message-State: AOAM530I5JgpjATZtO8Dpgay8xig2PdEB3jc000NEv9k/31S13xdod9i E1CWp4WP1BWuPk8j2v9qL7/Myg0MutB6Ig== X-Google-Smtp-Source: ABdhPJyis67JX/edsUfvdaj9esX/pPJI6VNKP8/w/iq3f97bKClA+v7K2GKPixlWMOJwwMhEP8KAnA== X-Received: by 2002:a63:6bc4:: with SMTP id g187mr5337417pgc.220.1638549991659; Fri, 03 Dec 2021 08:46:31 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:cd78:3a5f:d792:6177]) by smtp.gmail.com with ESMTPSA id h18sm4123149pfh.172.2021.12.03.08.46.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Dec 2021 08:46:31 -0800 (PST) From: Hirokazu Honda 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 Subject: [libcamera-devel] [PATCH 4/7] libcamera: camera_manager: Protect cameras_ by mutex in cleanup() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This fixes the bug that camera_ is accessed without acquiring mutex_ in CameraManager::Private::cleanup(). Signed-off-by: Hirokazu Honda --- src/libcamera/camera_manager.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp index 70d73822..4492edc3 100644 --- a/src/libcamera/camera_manager.cpp +++ b/src/libcamera/camera_manager.cpp @@ -178,7 +178,10 @@ void CameraManager::Private::cleanup() * process deletion requests from the thread's message queue as the event * loop is not in action here. */ + mutex_.lock(); cameras_.clear(); + mutex_.unlock(); + dispatchMessages(Message::Type::DeferredDelete); enumerator_.reset(nullptr);