{"id":22545,"url":"https://patchwork.libcamera.org/api/1.1/patches/22545/?format=json","web_url":"https://patchwork.libcamera.org/patch/22545/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20250113170724.801717-1-chenghaoyang@chromium.org>","date":"2025-01-13T17:06:56","name":"DmaBufAllocator: Avoid syncing with an invalid file descriptor","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":false,"hash":"0cc62c4a3c745bf0fd3bf793fe8cb106c593f2cf","submitter":{"id":117,"url":"https://patchwork.libcamera.org/api/1.1/people/117/?format=json","name":"Cheng-Hao Yang","email":"chenghaoyang@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/22545/mbox/","series":[{"id":4947,"url":"https://patchwork.libcamera.org/api/1.1/series/4947/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4947","date":"2025-01-13T17:06:56","name":"DmaBufAllocator: Avoid syncing with an invalid file descriptor","version":1,"mbox":"https://patchwork.libcamera.org/series/4947/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/22545/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/22545/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 213E1C326C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 13 Jan 2025 17:07:35 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2541868503;\n\tMon, 13 Jan 2025 18:07:34 +0100 (CET)","from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com\n\t[IPv6:2607:f8b0:4864:20::62a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1BFE2684E7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Jan 2025 18:07:32 +0100 (CET)","by mail-pl1-x62a.google.com with SMTP id\n\td9443c01a7336-21634338cfdso63707495ad.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Jan 2025 09:07:32 -0800 (PST)","from chenghaoyang-low.c.googlers.com.com\n\t(21.160.199.104.bc.googleusercontent.com. [104.199.160.21])\n\tby smtp.gmail.com with ESMTPSA id\n\td2e1a72fcca58-72d4067ee81sm6256303b3a.132.2025.01.13.09.07.29\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 13 Jan 2025 09:07:29 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"Xknt2VvZ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=chromium.org; s=google; t=1736788050; x=1737392850;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:from:to:cc:subject:date:message-id:reply-to;\n\tbh=uy20PlYmxv95KjKfx5pbj5Etq3c/K5m8G1F56/PKgKM=;\n\tb=Xknt2VvZ+qvew4hVrZ6s8YkPsJemQf/o3ljMl9L/BTeikRt78IBjkykdeFA17W6D1d\n\toeJwVFQvsh5DG9kV0rccxLlaWYvS0ugecQZpxxC1GaSZYGINrxgD3cBh+F6FFTFtJRo5\n\te5erD3VjMyY2QsJJwUmU5I84wavX7HP6DEIWs=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1736788050; x=1737392850;\n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:x-gm-message-state:from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==","X-Received":"by 2002:a05:6a00:1152:b0:725:f282:1f04 with SMTP id\n\td2e1a72fcca58-72d21fcf2d9mr30827239b3a.18.1736788050187; \n\tMon, 13 Jan 2025 09:07:30 -0800 (PST)","From":"Harvey Yang <chenghaoyang@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Cc":"Harvey Yang <chenghaoyang@chromium.org>","Subject":"[PATCH] DmaBufAllocator: Avoid syncing with an invalid file\n\tdescriptor","Date":"Mon, 13 Jan 2025 17:06:56 +0000","Message-ID":"<20250113170724.801717-1-chenghaoyang@chromium.org>","X-Mailer":"git-send-email 2.47.1.613.gc27f4b7a9f-goog","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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":"As DmaSyncer disables the copy c'tor, the move c'tor will be used\ninstead. This leaves some DmaSyncers with invalid SharedFDs. They should\navoid syncing with invalid file descriptors in the d'tor.\n\nFixes: 545046a41e17 (\"DmaBufAllocator: Make DmaSyncer non-copyable\")\nSigned-off-by: Harvey Yang <chenghaoyang@chromium.org>\n---\n src/libcamera/dma_buf_allocator.cpp | 5 +++++\n 1 file changed, 5 insertions(+)","diff":"diff --git a/src/libcamera/dma_buf_allocator.cpp b/src/libcamera/dma_buf_allocator.cpp\nindex a014c3b4263c..17a888efaa40 100644\n--- a/src/libcamera/dma_buf_allocator.cpp\n+++ b/src/libcamera/dma_buf_allocator.cpp\n@@ -330,6 +330,11 @@ DmaSyncer::~DmaSyncer()\n \n void DmaSyncer::sync(uint64_t step)\n {\n+\t// DmaSyncer might be moved and left an empty SharedFD.\n+\t// Avoid syncing with an invalid file descriptor in this case.\n+\tif (!fd_.isValid())\n+\t\treturn;\n+\n \tstruct dma_buf_sync sync = {\n \t\t.flags = flags_ | step\n \t};\n","prefixes":[]}