{"id":23093,"url":"https://patchwork.libcamera.org/api/1.1/patches/23093/?format=json","web_url":"https://patchwork.libcamera.org/patch/23093/","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":"<20250401131105.748536-1-barnabas.pocze@ideasonboard.com>","date":"2025-04-01T13:11:05","name":"[v2] pipeline: rpi: Fix potential empty optional read","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"e88ee1dee58f12f05e25194af3a83e09c32d6dae","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/1.1/people/216/?format=json","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/23093/mbox/","series":[{"id":5100,"url":"https://patchwork.libcamera.org/api/1.1/series/5100/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5100","date":"2025-04-01T13:11:05","name":"[v2] pipeline: rpi: Fix potential empty optional read","version":2,"mbox":"https://patchwork.libcamera.org/series/5100/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23093/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23093/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 6F5FBC323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  1 Apr 2025 13:11:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 855E368962;\n\tTue,  1 Apr 2025 15:11:11 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5609A6894F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  1 Apr 2025 15:11:09 +0200 (CEST)","from pb-laptop.local (185.221.143.221.nat.pool.zt.hu\n\t[185.221.143.221])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 21479741;\n\tTue,  1 Apr 2025 15:09:17 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"RYzAfD3J\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1743512957;\n\tbh=T9I6nZrwVzP2iRwj0W/f0jMH4eFEgh+0JJ619bpGocA=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=RYzAfD3J7ZSZuENt4DjyZF356N05r9MmxCLetX3Y0fLudmY4b9Zx9XZu7nn6SkPga\n\tU/+KAxgVx+wDTDMpKQ2hGDBljeQjZsEtZCJ3VqDCygLaw5e1NASByN0958mjr2ImxG\n\tYT128ubomuZDl2ZGVaSO2/OsHvyO2zsIMYhvtKy8=","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Subject":"[PATCH v2] pipeline: rpi: Fix potential empty optional read","Date":"Tue,  1 Apr 2025 15:11:05 +0200","Message-ID":"<20250401131105.748536-1-barnabas.pocze@ideasonboard.com>","X-Mailer":"git-send-email 2.49.0","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","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":"If `!target`, then `*target` is undefined behaviour, so check if the optional\nis empty when printing the error message. Simplify the check as well.\n\nFixes: 6c71ee1f153051 (\"pipeline: raspberrypi: Introduce PipelineHandlerBase class\")\nFixes: 841ef2b4bb08ba (\"pipeline: rpi: Add support for Raspberry Pi 5\")\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\nChanges in v2:\n  * fix the same issue in pisp as well\n---\n src/libcamera/pipeline/rpi/pisp/pisp.cpp | 4 ++--\n src/libcamera/pipeline/rpi/vc4/vc4.cpp   | 4 ++--\n 2 files changed, 4 insertions(+), 4 deletions(-)\n\n--\n2.49.0","diff":"diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp\nindex 42ca7c80b..91e7f4c94 100644\n--- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n+++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n@@ -1350,9 +1350,9 @@ int PiSPCameraData::platformPipelineConfigure(const std::unique_ptr<YamlObject>\n \t}\n\n \tstd::optional<std::string> target = (*root)[\"target\"].get<std::string>();\n-\tif (!target || *target != \"pisp\") {\n+\tif (target != \"pisp\") {\n \t\tLOG(RPI, Error) << \"Unexpected target reported: expected \\\"pisp\\\", got \"\n-\t\t\t\t<< *target;\n+\t\t\t\t<< (target ? target->c_str() : \"(unknown)\");\n \t\treturn -EINVAL;\n \t}\n\ndiff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\nindex fd8d84b14..fe910bdf2 100644\n--- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n+++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n@@ -510,9 +510,9 @@ int Vc4CameraData::platformPipelineConfigure(const std::unique_ptr<YamlObject> &\n \t}\n\n \tstd::optional<std::string> target = (*root)[\"target\"].get<std::string>();\n-\tif (!target || *target != \"bcm2835\") {\n+\tif (target != \"bcm2835\") {\n \t\tLOG(RPI, Error) << \"Unexpected target reported: expected \\\"bcm2835\\\", got \"\n-\t\t\t\t<< *target;\n+\t\t\t\t<< (target ? target->c_str() : \"(unknown)\");\n \t\treturn -EINVAL;\n \t}\n\n","prefixes":["v2"]}