{"id":14950,"url":"https://patchwork.libcamera.org/api/patches/14950/?format=json","web_url":"https://patchwork.libcamera.org/patch/14950/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20211201075348.3121186-11-hiroh@chromium.org>","date":"2021-12-01T07:53:46","name":"[libcamera-devel,v5,10/12] android: camera_device: Fix variables access without protection","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"62d98795c1390d9876c93acfe42d3f440a451c6c","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/14950/mbox/","series":[{"id":2791,"url":"https://patchwork.libcamera.org/api/series/2791/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2791","date":"2021-12-01T07:53:36","name":"Introduce clang thread safety annotations","version":5,"mbox":"https://patchwork.libcamera.org/series/2791/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14950/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14950/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 0D8A6BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  1 Dec 2021 07:54:16 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B9F5F60725;\n\tWed,  1 Dec 2021 08:54:15 +0100 (CET)","from mail-pg1-x536.google.com (mail-pg1-x536.google.com\n\t[IPv6:2607:f8b0:4864:20::536])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D670D60727\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  1 Dec 2021 08:54:13 +0100 (CET)","by mail-pg1-x536.google.com with SMTP id q16so22709912pgq.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 23:54:13 -0800 (PST)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:3892:a049:59ba:c772])\n\tby smtp.gmail.com with ESMTPSA id\n\tl9sm3500848pfu.55.2021.11.30.23.54.10\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 30 Nov 2021 23:54:11 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"mNT0xJqE\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=SdRdtSaVWQne/+wW0BuBr2489jUGsU+9DzmNFD9RRSU=;\n\tb=mNT0xJqE2t/JW87M9LAUBLMBhCxWyaNcEqJXjg0TLBEGrji/108TQvuutSTdTozDgY\n\t3BUAL24rbb/vj5JLdbw2jAV87Rrqo37I1pTzHeIFEn/QEZ/UgSfLpboRuXNacWMBsco4\n\t1+ClV193+WxN2q1206tVE8U5gwMq8w7/Pl6hs=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=SdRdtSaVWQne/+wW0BuBr2489jUGsU+9DzmNFD9RRSU=;\n\tb=MdJBigVknYBboCKMXbVaQkAOZYBpoiaZA1j/ipFbd5grqpzcOejT+lPcJaTGQcP4S1\n\tGNERdH6k7b0De5xXWVhx67s0GIaY6DZFfntV+8NEStdjzWsB+6AVV7oZtAaLmOvoH4zB\n\thcgfRl//sfWc29ADEj5Ahzd9lhn8UcFJaVt8U9qxLHq/N58p/JThnxU3M10phtjxj2Vy\n\tjQmxxH8iAsRGe2muL50O2i05kjQqqNbD5EErhPJCAHYo39wNidbBstrWiec50hzuCW64\n\tqhcMLPetqTSWCIBDj48FqOc18vOJ3VtcIjA8RREOkJdk3bg0bE2i0llneGcD1pdju0sQ\n\ttd6A==","X-Gm-Message-State":"AOAM5322FyeNQKIf4o5C64X0lKUhYdWb109PMry5Nq+L4Tf5CXUCfTug\n\t1o4U6lbM2ASIHYW64bESCToHJ+lXHRDzUg==","X-Google-Smtp-Source":"ABdhPJwogPHv0C8Gz8pC5FaNmENXLz6wFQuul7Xx5cy0MkVgcVtOK0RcLoz/pqv7fL6xChNpnCSedw==","X-Received":"by 2002:a62:7a92:0:b0:49f:9a0f:6bcd with SMTP id\n\tv140-20020a627a92000000b0049f9a0f6bcdmr4343153pfc.43.1638345252146; \n\tTue, 30 Nov 2021 23:54:12 -0800 (PST)","From":"Hirokazu Honda <hiroh@chromium.org>","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v5 10/12] android: camera_device: Fix\n\tvariables access without protection","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"This fixes the code accessing descriptors and\nCamera3RequestDescriptor::pendingStreamsToProcess_ without holding\ndescriptorsMutex_ and Camera3RequestDescriptor::streamProcessMutex_\nin CameraDevice.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/android/camera_device.cpp | 9 ++++++++-\n 1 file changed, 8 insertions(+), 1 deletion(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex d74307a2..c7de5da0 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -421,7 +421,11 @@ void CameraDevice::stop()\n \tworker_.stop();\n \tcamera_->stop();\n \n-\tdescriptors_ = {};\n+\t{\n+\t\tMutexLocker descriptorsLock(descriptorsMutex_);\n+\t\tdescriptors_ = {};\n+\t}\n+\n \tstreams_.clear();\n \n \tstate_ = State::Stopped;\n@@ -918,6 +922,9 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques\n \t\t */\n \t\tFrameBuffer *frameBuffer = nullptr;\n \t\tint acquireFence = -1;\n+\n+\t\tMutexLocker lock(descriptor->streamsProcessMutex_);\n+\n \t\tswitch (cameraStream->type()) {\n \t\tcase CameraStream::Type::Mapped:\n \t\t\t/*\n","prefixes":["libcamera-devel","v5","10/12"]}