[{"id":33707,"web_url":"https://patchwork.libcamera.org/comment/33707/","msgid":"<20250326020019.GE23984@pendragon.ideasonboard.com>","date":"2025-03-26T02:00:19","subject":"Re: [PATCH v1] pipeline: rpi: Fix potential empty optional read","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Barnabás,\n\nThank you for the patch.\n\nOn Tue, Mar 25, 2025 at 03:07:45PM +0100, Barnabás Pőcze wrote:\n> If `!target`, then `*target` is undefined behaviour, so check if the optional\n> is empty when printing the error message. Simplify the check as well.\n> \n> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/libcamera/pipeline/rpi/vc4/vc4.cpp | 4 ++--\n>  1 file changed, 2 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n> index 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>","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 0A085C3213\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 26 Mar 2025 02:00:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2F21C68952;\n\tWed, 26 Mar 2025 03:00:45 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 65BF3617F1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 26 Mar 2025 03:00:43 +0100 (CET)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 868CA3A4;\n\tWed, 26 Mar 2025 02:58:55 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"BfDHQUfD\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1742954335;\n\tbh=kHHsbnRg7+rndDZ32Yr+tGXGWCV8GyKgtEWJAiHNjt0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=BfDHQUfD1OnkfEA/KfXYZDUjzdNNYBrL0uhZXDg6uknC3iP7AwotjtJFjRzIhpIzN\n\tHvHUk+OoC4EmbEbqmkHNA8FRn9Kt+7zZRtx4UVxvNCgAL23rD/JjPqGXGavy2ybXIi\n\tw+heIZ4DmqqzeS1vAQ0Y8v4y7G4ZxkQARANX2saM=","Date":"Wed, 26 Mar 2025 04:00:19 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v1] pipeline: rpi: Fix potential empty optional read","Message-ID":"<20250326020019.GE23984@pendragon.ideasonboard.com>","References":"<20250325140745.1400058-1-barnabas.pocze@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20250325140745.1400058-1-barnabas.pocze@ideasonboard.com>","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>"}},{"id":33846,"web_url":"https://patchwork.libcamera.org/comment/33846/","msgid":"<174351218055.3394313.13910429109958715722@ping.linuxembedded.co.uk>","date":"2025-04-01T12:56:20","subject":"Re: [PATCH v1] pipeline: rpi: Fix potential empty optional read","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Naush,\n\nA relatively small patch for RPi here, LGTM, but are you happy with\nthis as a fix?\n\nQuoting Laurent Pinchart (2025-03-26 02:00:19)\n> Hi Barnabás,\n> \n> Thank you for the patch.\n> \n> On Tue, Mar 25, 2025 at 03:07:45PM +0100, Barnabás Pőcze wrote:\n> > If `!target`, then `*target` is undefined behaviour, so check if the optional\n> > is empty when printing the error message. Simplify the check as well.\n> > \n\nAny fixes tag suitable? (would make this list in the fixes log of the\nlibcamera release)\n\n--\nKieran\n\n\n> > Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> > ---\n> >  src/libcamera/pipeline/rpi/vc4/vc4.cpp | 4 ++--\n> >  1 file changed, 2 insertions(+), 2 deletions(-)\n> > \n> > diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n> > index 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> >       }\n> > \n> >       std::optional<std::string> target = (*root)[\"target\"].get<std::string>();\n> > -     if (!target || *target != \"bcm2835\") {\n> > +     if (target != \"bcm2835\") {\n> >               LOG(RPI, Error) << \"Unexpected target reported: expected \\\"bcm2835\\\", got \"\n> > -                             << *target;\n> > +                             << (target ? target->c_str() : \"(unknown)\");\n> >               return -EINVAL;\n> >       }\n> > \n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","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 34FF8C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  1 Apr 2025 12:56:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2676268981;\n\tTue,  1 Apr 2025 14:56:25 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1BD2768947\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  1 Apr 2025 14:56:24 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CEB976F9;\n\tTue,  1 Apr 2025 14:54:31 +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=\"Y8zdJJI8\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1743512071;\n\tbh=331x2Xa/qQv47xntpDp4XZ4OyRlMHvipHGA16RrFhBQ=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=Y8zdJJI8vbuyhnI293LSHw+MT6WWj3dUw1dYR/ZEnuUyTMrwXni5gSJWIf7n/fWgs\n\tCC8yCzeOEcKSSRhVVDkUrwh0HL0f0i0fFhqfSG8dWn4hDTWon0QWeLatbp26io768B\n\tLm/U2wrCQwYgA62Xuet/gWzWnnvWqxfqn55ejImU=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250326020019.GE23984@pendragon.ideasonboard.com>","References":"<20250325140745.1400058-1-barnabas.pocze@ideasonboard.com>\n\t<20250326020019.GE23984@pendragon.ideasonboard.com>","Subject":"Re: [PATCH v1] pipeline: rpi: Fix potential empty optional read","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>, Naushir Patuck\n\t<naush@raspberrypi.com>, ","Date":"Tue, 01 Apr 2025 13:56:20 +0100","Message-ID":"<174351218055.3394313.13910429109958715722@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>"}},{"id":33848,"web_url":"https://patchwork.libcamera.org/comment/33848/","msgid":"<a318597a-e2dd-4b25-93ec-db40baf739a4@ideasonboard.com>","date":"2025-04-01T13:12:39","subject":"Re: [PATCH v1] pipeline: rpi: Fix potential empty optional read","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"Hi\n\n\n2025. 04. 01. 14:56 keltezéssel, Kieran Bingham írta:\n> Hi Naush,\n> \n> A relatively small patch for RPi here, LGTM, but are you happy with\n> this as a fix?\n> \n> Quoting Laurent Pinchart (2025-03-26 02:00:19)\n>> Hi Barnabás,\n>>\n>> Thank you for the patch.\n>>\n>> On Tue, Mar 25, 2025 at 03:07:45PM +0100, Barnabás Pőcze wrote:\n>>> If `!target`, then `*target` is undefined behaviour, so check if the optional\n>>> is empty when printing the error message. Simplify the check as well.\n>>>\n> \n> Any fixes tag suitable? (would make this list in the fixes log of the\n> libcamera release)\n\nI have sent a new version with the tags I believe are appropriate.\nAnd I have also discovered that pisp has the same issue, so I fixed\nthat too in the version.\n\n\nRegards,\nBarnabás Pőcze\n\n> \n> --\n> Kieran\n> \n> \n>>> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n>>\n>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>>\n>>> ---\n>>>   src/libcamera/pipeline/rpi/vc4/vc4.cpp | 4 ++--\n>>>   1 file changed, 2 insertions(+), 2 deletions(-)\n>>>\n>>> diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n>>> index 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>>>        }\n>>>\n>>>        std::optional<std::string> target = (*root)[\"target\"].get<std::string>();\n>>> -     if (!target || *target != \"bcm2835\") {\n>>> +     if (target != \"bcm2835\") {\n>>>                LOG(RPI, Error) << \"Unexpected target reported: expected \\\"bcm2835\\\", got \"\n>>> -                             << *target;\n>>> +                             << (target ? target->c_str() : \"(unknown)\");\n>>>                return -EINVAL;\n>>>        }\n>>>\n>>\n>> -- \n>> Regards,\n>>\n>> Laurent Pinchart","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 89F6EC323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  1 Apr 2025 13:12:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 426FD68985;\n\tTue,  1 Apr 2025 15:12:46 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 774F56894F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  1 Apr 2025 15:12:44 +0200 (CEST)","from [192.168.33.14] (185.221.143.221.nat.pool.zt.hu\n\t[185.221.143.221])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 36281741;\n\tTue,  1 Apr 2025 15:10:52 +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=\"a4EvhY26\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1743513052;\n\tbh=r865csRBIwyiz1GEKRpx/nGR+eePBUVchGJIPkWkXkE=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=a4EvhY268uXGPZgyudmk9AwhVydeOzhZ9I9isNSs3H0yaa/umOGf4vs01HsxbdZu7\n\tgQau1R4oXP4edY3L1RmirgzI76aKAJ/1sv+JcWRb7KsgsbUpFplcO03q5JnVaAI/GF\n\tIKwEzaJBjz6IpNhUd1rBkcFwEx9Bm/3/30K1yAkI=","Message-ID":"<a318597a-e2dd-4b25-93ec-db40baf739a4@ideasonboard.com>","Date":"Tue, 1 Apr 2025 15:12:39 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v1] pipeline: rpi: Fix potential empty optional read","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tNaushir Patuck <naush@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","References":"<20250325140745.1400058-1-barnabas.pocze@ideasonboard.com>\n\t<20250326020019.GE23984@pendragon.ideasonboard.com>\n\t<174351218055.3394313.13910429109958715722@ping.linuxembedded.co.uk>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<174351218055.3394313.13910429109958715722@ping.linuxembedded.co.uk>","Content-Type":"text/plain; charset=UTF-8; format=flowed","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>"}}]