{"id":11732,"url":"https://patchwork.libcamera.org/api/1.1/patches/11732/?format=json","web_url":"https://patchwork.libcamera.org/patch/11732/","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":"<20210326220410.329299-1-pnguyen@baylibre.com>","date":"2021-03-26T22:04:10","name":"[libcamera-devel,v2] android: camera_device: Add null check for ScalerCrop control","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"611903ad2d7efd343ff5dbcc069b879dbca341a4","submitter":{"id":79,"url":"https://patchwork.libcamera.org/api/1.1/people/79/?format=json","name":"Phi-bang Nguyen","email":"pnguyen@baylibre.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/11732/mbox/","series":[{"id":1841,"url":"https://patchwork.libcamera.org/api/1.1/series/1841/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1841","date":"2021-03-26T22:04:10","name":"[libcamera-devel,v2] android: camera_device: Add null check for ScalerCrop control","version":2,"mbox":"https://patchwork.libcamera.org/series/1841/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11732/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11732/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 79F24C32EB\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 26 Mar 2021 22:04:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B9AD968D6D;\n\tFri, 26 Mar 2021 23:04:38 +0100 (CET)","from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com\n\t[IPv6:2a00:1450:4864:20::42d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1F77568D6A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Mar 2021 23:04:38 +0100 (CET)","by mail-wr1-x42d.google.com with SMTP id x7so6973547wrw.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Mar 2021 15:04:38 -0700 (PDT)","from localhost.localdomain (206.159.69.91.rev.sfr.net.\n\t[91.69.159.206]) by smtp.googlemail.com with ESMTPSA id\n\tp6sm15013885wru.2.2021.03.26.15.04.37\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 26 Mar 2021 15:04:37 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=baylibre-com.20150623.gappssmtp.com\n\theader.i=@baylibre-com.20150623.gappssmtp.com\n\theader.b=\"V61t+4i1\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=baylibre-com.20150623.gappssmtp.com; s=20150623;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=BC7q5wsotl3CYVZQ18BXqI4yqE8oHDVSV0o66Wa0g70=;\n\tb=V61t+4i1gnpVW2mozRgNBnGN2zNbLi2EAczjvR2s33gzTx7bkBjM+qv3PstGrq/raO\n\tTuGLchkfswO4aOdD6XjAFF2L+GKrYtFOK9+NDs+2XIhNTfcsdzIXs5kfBnKe1+NU78pG\n\tRXHl9mQlwWcCQIah4qBh5juHpb88GUUS/xQL2nQiyAEIPRGehkXynkhN0ba54ApDcU6g\n\tLXdIHimXyDz11ZnBTijrMWHrNm1d5KmpJpUxw2uQPj4mmDISULhaiNvGpj76U15EPbUG\n\t2+MIhaFT5FQrgAwqw5jqGNq87Gmv4EuJEelcsV+BbqZD8PMtBUe/WCADOcxcMFCYRl8T\n\tBoGA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\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=BC7q5wsotl3CYVZQ18BXqI4yqE8oHDVSV0o66Wa0g70=;\n\tb=aJMlPHBihHsfC1rImciIXrJ4H37Mmba/Mn+2Pqqv2uGN3fGIyiWiA+8htDnhBJixzx\n\tUN9RKA852tPzYLdY4r/FsywEzdUVwtQO2ZlCw1CJAYjxibPaXLbf3ftix4+qnheph1xw\n\tbGI0BAEdj49bwLt6oYpPtz8SkYYUCDGyxgxBbYC/3w35RV/0GEz8ujCmlJNMHMGLVZcL\n\tDyIzVB+V6FlaO/mVmYmPwxno1+ndxo7G1ErYgm8jZ0cf7YcCf4DXW3glvhTbz/6g166S\n\t6vOgmd6eU3Kq+Q5uIvLrLCAXdJNB0kM0wkShMQuD4qbjJ8PcFL3zY+pY64VLCI9o9gvQ\n\tyM5Q==","X-Gm-Message-State":"AOAM530UD3eLWWxaZQBFJe9dnVok5ZerRdCZsYgpll2sS6bCibwQ0GiH\n\tIqJft5J799zmhwsYcR/s4OCGVg==","X-Google-Smtp-Source":"ABdhPJwQVITHAs6UkU2iqpuP/SrF4eYFPvXIAnggtfWpfcrllV3CYPlS0GRy7uGOBwCsEp8GU7cMfQ==","X-Received":"by 2002:a05:6000:362:: with SMTP id\n\tf2mr8430851wrf.141.1616796277805; \n\tFri, 26 Mar 2021 15:04:37 -0700 (PDT)","From":"Phi-Bang Nguyen <pnguyen@baylibre.com>","To":"laurent.pinchart@ideasonboard.com","Date":"Fri, 26 Mar 2021 23:04:10 +0100","Message-Id":"<20210326220410.329299-1-pnguyen@baylibre.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<YF49KirQp2QUQ1LA@pendragon.ideasonboard.com>","References":"<YF49KirQp2QUQ1LA@pendragon.ideasonboard.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v2] android: camera_device: Add null check\n\tfor ScalerCrop control","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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The ScalerCrop control does not contain the null check which can\ncause the camera HAL crash at boot. Fix it.\n\nSigned-off-by: Phi-Bang Nguyen <pnguyen@baylibre.com>\n---\n src/android/camera_device.cpp | 11 +++++++----\n 1 file changed, 7 insertions(+), 4 deletions(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex ae693664..a8108e3a 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -1107,11 +1107,14 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()\n \t\t * use the maximum and minimum crop rectangles to calculate the\n \t\t * digital zoom factor.\n \t\t */\n+\t\tfloat maxZoom = { 1 };\n \t\tconst auto info = controlsInfo.find(&controls::ScalerCrop);\n-\t\tRectangle min = info->second.min().get<Rectangle>();\n-\t\tRectangle max = info->second.max().get<Rectangle>();\n-\t\tfloat maxZoom = std::min(1.0f * max.width / min.width,\n-\t\t\t\t\t 1.0f * max.height / min.height);\n+\t\tif (info != controlsInfo.end()) {\n+\t\t\tRectangle min = info->second.min().get<Rectangle>();\n+\t\t\tRectangle max = info->second.max().get<Rectangle>();\n+\t\t\tmaxZoom = std::min(1.0f * max.width / min.width,\n+\t\t\t\t\t   1.0f * max.height / min.height);\n+\t\t}\n \t\tstaticMetadata_->addEntry(ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM,\n \t\t\t\t\t  &maxZoom, 1);\n \t}\n","prefixes":["libcamera-devel","v2"]}