From patchwork Wed Dec 1 07:07:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14936 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 CEEDFBDB13 for ; Wed, 1 Dec 2021 07:07:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8748760720; Wed, 1 Dec 2021 08:07:56 +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="BhBksRNQ"; 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 DDB1F60720 for ; Wed, 1 Dec 2021 08:07:53 +0100 (CET) Received: by mail-pg1-x52c.google.com with SMTP id 137so15552668pgg.3 for ; Tue, 30 Nov 2021 23:07:53 -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=BhBksRNQ52z8DCgmnV0UwKdMSk/zvSR1QqtdqSva7lO2c5e7UCIoEfJ3ZwOy8fO0de VsZyiyc1BbcixIJcGQFp4Ar5BMVlNpl03pmIaD9salRqNHJO50XN7O7p1QHZtUnO8wFZ qgFdhdk2D06gWACTGSut95E6teaDkgGX2R+qA= 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=bzgBuqPzZvxRqKhIZvhDncnVpUbgiM93/6rwOCCVGq3bRAiervYHURrkZb7asl/r94 l5MPoRS6p7+Cw+AeU2T/VO1yIKNPpFLOd/tnJ4iaDHeL/RYcpaE0qcy908U6C5O7b/+F dQYHTDAPUwZwZba7C+ErIm5eGlMeuSYMfnqvF7ioQgefwJQh9sHtx3gXKD+3dBx6LD3V I0x24wsrtjbi0kj6jEiKGKolf+X3k1XxmXL+8iHJK9F0MjuVzaAmzxA+ngCB0xyMzf85 vL3fS44VNOGfjYVh+lyrB8kaDELzVCE6DBFS7Tft1t5tdCNTkCiG6XDWllFrBlLboUgd pIHA== X-Gm-Message-State: AOAM533OUSkkOhyNUUMJE5bYLYf6whnnCeEp26HcX9YFXv491KpLZpis YXog6XPhefHxmWqGpU+ZoPEkZojT5BE2lA== X-Google-Smtp-Source: ABdhPJwi93Gr9q8pHWYVzJiKGXRAQMzBKPeJUnY8eUKU96QJIgHJNMFJkuRDKrF1N5o6bDdsu1a2LQ== X-Received: by 2002:a63:81c8:: with SMTP id t191mr3340297pgd.369.1638342472172; Tue, 30 Nov 2021 23:07:52 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:3892:a049:59ba:c772]) by smtp.gmail.com with ESMTPSA id m10sm16598962pgv.75.2021.11.30.23.07.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 23:07:51 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 1 Dec 2021 16:07:26 +0900 Message-Id: <20211201070728.3114247-11-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog In-Reply-To: <20211201070728.3114247-1-hiroh@chromium.org> References: <20211201070728.3114247-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 | 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: /*