Patch Detail
Show a patch.
GET /api/1.1/patches/18524/?format=api
{ "id": 18524, "url": "https://patchwork.libcamera.org/api/1.1/patches/18524/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18524/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20230404-guard-idmap-v2-1-444d135b3895@baylibre.com>", "date": "2023-04-05T08:14:30", "name": "[libcamera-devel,v2,1/2] libcamera: controls: guard ControlInfoMap against nullptr idmap_", "commit_ref": "3dc2605bda52b627f6e009ef4a3c8360d00e358a", "pull_url": null, "state": "accepted", "archived": false, "hash": "037d4c7fff653f3b34df2ae166489959d44ef7dd", "submitter": { "id": 153, "url": "https://patchwork.libcamera.org/api/1.1/people/153/?format=api", "name": "Mattijs Korpershoek", "email": "mkorpershoek@baylibre.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18524/mbox/", "series": [ { "id": 3836, "url": "https://patchwork.libcamera.org/api/1.1/series/3836/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3836", "date": "2023-04-05T08:14:29", "name": "libcamera: controls: guard ControlInfoMap against nullptr idmap_", "version": 2, "mbox": "https://patchwork.libcamera.org/series/3836/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18524/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18524/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 992A1C32A3\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 5 Apr 2023 08:14:44 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EB11B62767;\n\tWed, 5 Apr 2023 10:14:42 +0200 (CEST)", "from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com\n\t[IPv6:2a00:1450:4864:20::32a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D68F061EC4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 5 Apr 2023 10:14:40 +0200 (CEST)", "by mail-wm1-x32a.google.com with SMTP id s13so20363158wmr.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 05 Apr 2023 01:14:40 -0700 (PDT)", "from [192.168.1.20] ([2a01:cb19:85e6:1900:2bf7:7388:731d:c4e1])\n\tby smtp.gmail.com with ESMTPSA id\n\tp11-20020a05600c1d8b00b003ef36ef3833sm1403957wms.8.2023.04.05.01.14.39\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 05 Apr 2023 01:14:40 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1680682482;\n\tbh=FtnHyAOR90JiVUYsn1W0VqIDMDythWC2N1zlHI/d0o4=;\n\th=Date:References:In-Reply-To:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=QD1xt+moa+Vx2BwTYwHJEP9bvxIi4uZm9w2I+B+Ddg5y2ueJ4iFcWKlK2+jGWwxZK\n\t0L5BG6ggqBJb+LtGlU/EbLbzqF/8eujLw9JihJGOcFXFas033vJz/xnj0wXyp2dKmR\n\t451gr5p09juRXtsDr3puAD3d9nOAQ0EBsNpjGthA56L2/Peo3qHefSJWclWrHvgGcU\n\tkyXI721+XFjIH4Nu0tR//Y3D6DxbiwxfYEPRtgcdDCfycuT2rCi4NJdGS6MK2tY+0R\n\tjFQKn8DuroVxs2iVmkW9AgcYgo0SUzBElWNy0zGkEwKPBl3lHpIHiYPv8vaJkpF6aA\n\t6RfA/nS3J1/Wg==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1680682480;\n\th=cc:to:in-reply-to:references:message-id:content-transfer-encoding\n\t:mime-version:subject:date:from:from:to:cc:subject:date:message-id\n\t:reply-to; bh=mygre3XJMw6fTJh+BG3yPWhv4WZFhNQpRIGnoctMzA4=;\n\tb=Ka9sOf2fNHXmKMRwNp+aalSOPAogxJD2LgxrnThy4GFLIHs5/hLt0ukYiNP4l05bzj\n\ta6XgNiCGFjONFHrczCorpaZrHbzg+TmgGNS2weXmWabC26GyVaGGqG1dow4Qkg/7bx1S\n\t+CrU5vNBbFO/FDIxHzQ9ZHWOvGO0Bzvj4RZ6ZWRXuQEL1ZWGyVEMIa+tyvC08THDmiRf\n\trG50zP873LHWyM+oSgoLshr3XdRnFk9K8ImcyZQILHJ9d7ow6jyPWw5SmWFl5yP8uXiN\n\tzipIWiuw87fNzI6Wegi0hchc6MPF+n1rRwpSHJFQtCaGjTjOpQG/haNqSgUzkDX98boq\n\tbTOw==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=baylibre-com.20210112.gappssmtp.com\n\theader.i=@baylibre-com.20210112.gappssmtp.com header.b=\"Ka9sOf2f\"; \n\tdkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112; t=1680682480;\n\th=cc:to:in-reply-to:references:message-id:content-transfer-encoding\n\t:mime-version:subject:date:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=mygre3XJMw6fTJh+BG3yPWhv4WZFhNQpRIGnoctMzA4=;\n\tb=pkooAF4qjd8BarictdlLoNY+lfxhoVghyhypTyU28xGI2v9iEnHecl7adP03G/0bGB\n\tZ/dcW5BPZMjRoIMY6Lna7VCS01Hh8/6P6p79mSW+ga5c1BU9azV3oabRE5PhlvnNRxnu\n\trCfNqHxcjHh9zAX582YOsa2Xcqg1ctwi7gdVXBPxAQ2UYCRe97Lx0L3oKhWyczCcxA/v\n\tfAonF/DhsaG1mlnyBxNENWgCzRuRufEKVJCsxAGRqSi/mfDbZhFFovhrVtM2C3iZKRDb\n\tajRUvr+m3VYdLW0fHvzfqgGR5CLTcmtgmS9bpofyM+KOwuxdcqIXKt/ZFdeqkFyudqdF\n\t7K/g==", "X-Gm-Message-State": "AAQBX9de/ClqBN7DhTOM98pQqxb2kvcCPLepvm2V/kpzXC+I6xJns+Gh\n\tRbsHQ4PHL/V96jmhvLknhikdzA==", "X-Google-Smtp-Source": "AKy350Y+wojnIYEGcoI1WQQxFnIpsBbqcE3YafpBm9e6SACIJpDEIktlT0DDKYrCSKnQNNuypVvLYw==", "X-Received": "by 2002:a7b:c395:0:b0:3ee:9c0e:c78f with SMTP id\n\ts21-20020a7bc395000000b003ee9c0ec78fmr3676459wmj.5.1680682480491; \n\tWed, 05 Apr 2023 01:14:40 -0700 (PDT)", "Date": "Wed, 05 Apr 2023 10:14:30 +0200", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "7bit", "Message-Id": "<20230404-guard-idmap-v2-1-444d135b3895@baylibre.com>", "References": "<20230404-guard-idmap-v2-0-444d135b3895@baylibre.com>", "In-Reply-To": "<20230404-guard-idmap-v2-0-444d135b3895@baylibre.com>", "To": "libcamera-devel@lists.libcamera.org", "X-Mailer": "b4 0.13-dev-00303", "Subject": "[libcamera-devel] [PATCH v2 1/2] libcamera: controls: guard\n\tControlInfoMap against nullptr idmap_", "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>", "From": "Mattijs Korpershoek via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Mattijs Korpershoek <mkorpershoek@baylibre.com>", "Cc": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "It's possible to construct a Camera with an unsafe controlInfo_.\nThis is the case in the Simple pipeline, where the camera controls are\nnot populated.\n\nWith Simple, if we attempt to set a Control, we end up with a segfault\nbecause the default constructor for ControlInfoMap doesn't\nintialized idmap_ which is initialized at class declaration time as\n\n const ControlIdMap *idmap_ = nullptr;\n\nAdd some safeguards in ControlInfoMap to handle this case.\n\nLink: https://lists.libcamera.org/pipermail/libcamera-devel/2023-April/037439.html\nSuggested-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nSigned-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n src/libcamera/controls.cpp | 16 ++++++++++++++++\n 1 file changed, 16 insertions(+)", "diff": "diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex 6dbf9b348709..b808116c01e5 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -677,6 +677,9 @@ ControlInfoMap::ControlInfoMap(Map &&info, const ControlIdMap &idmap)\n \n bool ControlInfoMap::validate()\n {\n+\tif (!idmap_)\n+\t\treturn false;\n+\n \tfor (const auto &ctrl : *this) {\n \t\tconst ControlId *id = ctrl.first;\n \t\tauto it = idmap_->find(id->id());\n@@ -719,6 +722,8 @@ bool ControlInfoMap::validate()\n */\n ControlInfoMap::mapped_type &ControlInfoMap::at(unsigned int id)\n {\n+\tASSERT(idmap_);\n+\n \treturn at(idmap_->at(id));\n }\n \n@@ -729,6 +734,8 @@ ControlInfoMap::mapped_type &ControlInfoMap::at(unsigned int id)\n */\n const ControlInfoMap::mapped_type &ControlInfoMap::at(unsigned int id) const\n {\n+\tASSERT(idmap_);\n+\n \treturn at(idmap_->at(id));\n }\n \n@@ -739,6 +746,9 @@ const ControlInfoMap::mapped_type &ControlInfoMap::at(unsigned int id) const\n */\n ControlInfoMap::size_type ControlInfoMap::count(unsigned int id) const\n {\n+\tif (!idmap_)\n+\t\treturn 0;\n+\n \t/*\n \t * The ControlInfoMap and its idmap have a 1:1 mapping between their\n \t * entries, we can thus just count the matching entries in idmap to\n@@ -755,6 +765,9 @@ ControlInfoMap::size_type ControlInfoMap::count(unsigned int id) const\n */\n ControlInfoMap::iterator ControlInfoMap::find(unsigned int id)\n {\n+\tif (!idmap_)\n+\t\treturn end();\n+\n \tauto iter = idmap_->find(id);\n \tif (iter == idmap_->end())\n \t\treturn end();\n@@ -770,6 +783,9 @@ ControlInfoMap::iterator ControlInfoMap::find(unsigned int id)\n */\n ControlInfoMap::const_iterator ControlInfoMap::find(unsigned int id) const\n {\n+\tif (!idmap_)\n+\t\treturn end();\n+\n \tauto iter = idmap_->find(id);\n \tif (iter == idmap_->end())\n \t\treturn end();\n", "prefixes": [ "libcamera-devel", "v2", "1/2" ] }