From patchwork Wed Dec 1 07:53:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14950 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 0D8A6BF415 for ; Wed, 1 Dec 2021 07:54:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B9F5F60725; Wed, 1 Dec 2021 08:54:15 +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="mNT0xJqE"; dkim-atps=neutral Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D670D60727 for ; Wed, 1 Dec 2021 08:54:13 +0100 (CET) Received: by mail-pg1-x536.google.com with SMTP id q16so22709912pgq.10 for ; Tue, 30 Nov 2021 23:54:13 -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=SdRdtSaVWQne/+wW0BuBr2489jUGsU+9DzmNFD9RRSU=; b=mNT0xJqE2t/JW87M9LAUBLMBhCxWyaNcEqJXjg0TLBEGrji/108TQvuutSTdTozDgY 3BUAL24rbb/vj5JLdbw2jAV87Rrqo37I1pTzHeIFEn/QEZ/UgSfLpboRuXNacWMBsco4 1+ClV193+WxN2q1206tVE8U5gwMq8w7/Pl6hs= 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=SdRdtSaVWQne/+wW0BuBr2489jUGsU+9DzmNFD9RRSU=; b=MdJBigVknYBboCKMXbVaQkAOZYBpoiaZA1j/ipFbd5grqpzcOejT+lPcJaTGQcP4S1 GNERdH6k7b0De5xXWVhx67s0GIaY6DZFfntV+8NEStdjzWsB+6AVV7oZtAaLmOvoH4zB hcgfRl//sfWc29ADEj5Ahzd9lhn8UcFJaVt8U9qxLHq/N58p/JThnxU3M10phtjxj2Vy jQmxxH8iAsRGe2muL50O2i05kjQqqNbD5EErhPJCAHYo39wNidbBstrWiec50hzuCW64 qhcMLPetqTSWCIBDj48FqOc18vOJ3VtcIjA8RREOkJdk3bg0bE2i0llneGcD1pdju0sQ td6A== X-Gm-Message-State: AOAM5322FyeNQKIf4o5C64X0lKUhYdWb109PMry5Nq+L4Tf5CXUCfTug 1o4U6lbM2ASIHYW64bESCToHJ+lXHRDzUg== X-Google-Smtp-Source: ABdhPJwogPHv0C8Gz8pC5FaNmENXLz6wFQuul7Xx5cy0MkVgcVtOK0RcLoz/pqv7fL6xChNpnCSedw== X-Received: by 2002:a62:7a92:0:b0:49f:9a0f:6bcd with SMTP id v140-20020a627a92000000b0049f9a0f6bcdmr4343153pfc.43.1638345252146; Tue, 30 Nov 2021 23:54:12 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:3892:a049:59ba:c772]) by smtp.gmail.com with ESMTPSA id l9sm3500848pfu.55.2021.11.30.23.54.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 23:54:11 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 1 Dec 2021 16:53:46 +0900 Message-Id: <20211201075348.3121186-11-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog In-Reply-To: <20211201075348.3121186-1-hiroh@chromium.org> References: <20211201075348.3121186-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 Reviewed-by: Umang Jain --- src/android/camera_device.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index d74307a2..c7de5da0 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,9 @@ 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: /*