From patchwork Tue Nov 30 15:55:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14907 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 2A4B9C324F for ; Tue, 30 Nov 2021 15:56:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CFFFA60723; Tue, 30 Nov 2021 16:56:30 +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="NMV5WYyG"; dkim-atps=neutral Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3CE5960726 for ; Tue, 30 Nov 2021 16:56:27 +0100 (CET) Received: by mail-pj1-x102f.google.com with SMTP id p18-20020a17090ad31200b001a78bb52876so18619792pju.3 for ; Tue, 30 Nov 2021 07:56:27 -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=Tsh0ApXzuilv6KhoR6vFwK3R224VNxnPJpnFf/qtahg=; b=NMV5WYyGHr0N5C+ZjPPGUqX1iBMRa8k0MHaM3s5JCoKQA/zEiDpeBMlykT99YuHGA7 hUyswhm+jnZoPBzTERHGblAkp5FXuMiZ/UYxWIMG24sIOvKvbq6AHU5YKMqHJQi0lr56 7uo7zcepi9j5h6FH+zpNQTc+VifpByhpCnK3A= 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=Tsh0ApXzuilv6KhoR6vFwK3R224VNxnPJpnFf/qtahg=; b=4OTh6xbsf2GBjtsZbvGfXG6Hp+Jg1vU/NDypFSf+KOFX/0kyI23uyQyddvxReEOjAm i+qOYRAlreh1PSrIS20OUEZt+dEYVvITNb9Qywnk4EsmwaVCgHE7sHUISqOjCqW0TmzF PVBX7RlJshoEDJ3sEv4EVxj2HQbJ0Bxipr2rU+2NQZp5rNvcT7uyWBoqlt9LqjO5fDM2 73qEHmnIU6qd2ArafI8PyEfGi1VIDOWPVK3nyGMbID0vnknk/oHpUnhvSQEYovPDBVpF tFJw43SkZYbLWTGwuUBSQ3ucAUsOYfYA+NoRLR4fG4Z/oRmfEjcxMhwBlrW0r6nyPFGN UdpQ== X-Gm-Message-State: AOAM530UuvRu/5SQ4IF80XFmZoNnNH+0/pOJnH49hFamFSQaQGKcw3rG WaRjSIqwfg2Sgae2YfwXR2aT9iDIb2LjPQ== X-Google-Smtp-Source: ABdhPJyFAypmTM1vI7ia5kplJF66NJiHs5OFzuy6PlPR9GAmL2XWWPipeC/et3C7G8TMJHJvb/IxDg== X-Received: by 2002:a17:90b:4c8c:: with SMTP id my12mr262389pjb.157.1638287785518; Tue, 30 Nov 2021 07:56:25 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:c90a:5a53:b139:1336]) by smtp.gmail.com with ESMTPSA id pc10sm3510283pjb.9.2021.11.30.07.56.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 07:56:24 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 1 Dec 2021 00:55:58 +0900 Message-Id: <20211130155600.2203123-11-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog In-Reply-To: <20211130155600.2203123-1-hiroh@chromium.org> References: <20211130155600.2203123-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 10/12] android: camera_device: Fix variables access without protection 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 code accessing descriptors and Camera3RequestDescriptor::pendingStreamsToProcess_ without holding descriptorsMutex_ and Camera3RequestDescriptor::streamProcessMutex_ in CameraDevice. Signed-off-by: Hirokazu Honda Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index d74307a2..e513cd84 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -421,7 +421,11 @@ void CameraDevice::stop() worker_.stop(); camera_->stop(); - descriptors_ = {}; + { + MutexLocker descriptorsLock(descriptorsMutex_); + descriptors_ = {}; + } + streams_.clear(); state_ = State::Stopped; @@ -918,6 +922,8 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques */ FrameBuffer *frameBuffer = nullptr; int acquireFence = -1; + + MutexLocker lock(descriptor->streamsProcessMutex_); switch (cameraStream->type()) { case CameraStream::Type::Mapped: /*