From patchwork Mon Nov 29 11:44:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14845 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 6677BC324F for ; Mon, 29 Nov 2021 11:45:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 02A60605A4; Mon, 29 Nov 2021 12:45:21 +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="gcl9fDDj"; dkim-atps=neutral Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3C5ED605B4 for ; Mon, 29 Nov 2021 12:45:17 +0100 (CET) Received: by mail-pg1-x52c.google.com with SMTP id j11so5912406pgs.2 for ; Mon, 29 Nov 2021 03:45:17 -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=3hURich/YKThkPSvS6bZkc/0Va6fPvKyJyaJXHVlALU=; b=gcl9fDDjUMS/XbVhHzWIAEX78M+2YfgLFXritbrcKha9Nmq0JLqSckxugrfbzk5e0N STzHlr2Yxu2sR0N4qdmFn4KDl11/okmK9a5CttClNRPHqp0OHTGMX5FQCiZZBO/+VzFY LbvHShWPex7h7NazG2EP2sFLneHxY+le6G4f4= 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=3hURich/YKThkPSvS6bZkc/0Va6fPvKyJyaJXHVlALU=; b=8KfUX8x5BUugUQn2bqt+3hhzGe6PTo/x8O4pXz1a3b3bw1l/5cNYDLVTZf0aufQAOj nDI2FFF3Isa5/1lz3HnLyQ4qpm+A05+PSXY0qdSH131dhNHQh4EQt8kRakRI2Zu6ppnz 6h08BuGcNwVAteyYq1g5yuiTPYoCV8m+bwGGTRPxZUHCCuZa+4nf7gHte0z1yfJd0f95 w11FnWJnWJ1JJUksZRgC4zhXvQCRkOBziuMyFiXdL0U0MLTJJPwHcvgWUfpWrt5Y+ZSb B0aYCB/hA/bvC13knSAY20azNmXK5epd29hKliLENxTKmStKMH4kCX6wzRPPwCGq70I8 i4Uw== X-Gm-Message-State: AOAM530+0LMUcwHS/1WLiIw6x7Dv+knW9+rbbBbjq1GyD3Rhw/SkEq64 wC4BFh8cHjNAsW8+/GkhoI8F8WmV7qz75w== X-Google-Smtp-Source: ABdhPJxupCe9ZR4ZpE9W171VeDKCZzpxv8wHOxpkzr2kd8ZYbw4siyJC9+H6dXt54nRyRTfI/6Usgg== X-Received: by 2002:a63:4c45:: with SMTP id m5mr22817120pgl.105.1638186315389; Mon, 29 Nov 2021 03:45:15 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:f254:cda9:46e8:17b7]) by smtp.gmail.com with ESMTPSA id hg4sm17951966pjb.1.2021.11.29.03.45.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 03:45:14 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Nov 2021 20:44:51 +0900 Message-Id: <20211129114453.3186042-10-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog In-Reply-To: <20211129114453.3186042-1-hiroh@chromium.org> References: <20211129114453.3186042-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 09/11] 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 --- 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 f2e0bdbd..59185e7f 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -422,7 +422,11 @@ void CameraDevice::stop() worker_.stop(); camera_->stop(); - descriptors_ = {}; + { + MutexLocker descriptorsLock(descriptorsMutex_); + descriptors_ = {}; + } + streams_.clear(); state_ = State::Stopped; @@ -919,6 +923,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: /*