{"id":15990,"url":"https://patchwork.libcamera.org/api/1.1/patches/15990/?format=json","web_url":"https://patchwork.libcamera.org/patch/15990/","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":"<20220520124919.2873559-1-naush@raspberrypi.com>","date":"2022-05-20T12:49:19","name":"[libcamera-devel] pipeline: raspberrypi: Fix possible null dereference","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"e7282df5bb1e310f3e19c1e91eb0c7cc96f476be","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/1.1/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15990/mbox/","series":[{"id":3130,"url":"https://patchwork.libcamera.org/api/1.1/series/3130/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3130","date":"2022-05-20T12:49:19","name":"[libcamera-devel] pipeline: raspberrypi: Fix possible null dereference","version":1,"mbox":"https://patchwork.libcamera.org/series/3130/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15990/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15990/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 99B1DC3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 20 May 2022 12:49:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F058F65660;\n\tFri, 20 May 2022 14:49:25 +0200 (CEST)","from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com\n\t[IPv6:2a00:1450:4864:20::32d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D321760440\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 May 2022 14:49:24 +0200 (CEST)","by mail-wm1-x32d.google.com with SMTP id\n\tp5-20020a1c2905000000b003970dd5404dso4301184wmp.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 May 2022 05:49:24 -0700 (PDT)","from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:c51d:7ffc:b6ae:6da2])\n\tby smtp.gmail.com with ESMTPSA id\n\to3-20020a1c4d03000000b003942a244f30sm2356656wmh.9.2022.05.20.05.49.23\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 20 May 2022 05:49:23 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1653050966;\n\tbh=lbgUVdL/IiYXwBlZpkdcSOpYFudlePhM0LgzAZUX8Cc=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=fPNsUWEI0WfY/w8uyKodhletGb/rM7Z9d+EYUe1fEU218odcS7Zxb82oY30IhBPTP\n\t1ypupmjkLTpCPtL2LO3cR0IT3qsBQlxA5mxvJl8Le62n4dIzR2s8SeEZz5CeiFiOR9\n\tZSZkxmILS5lnQCRSplU7o40s1z5ds/hoTuD+PGMgyjrgWgaRFS6od6jCfkB9B6wGcz\n\tZfTfA1a6RKUzNvx1TZ9BkxvIh9y6AFIrBbzqnSBBoyVk7058+3eZ0ZKZIQZyufPkDQ\n\twC18y0Z6H1lHjv4NgeezvencVaS0q2nH6upIgwzlEJYdEs9geSSkR8ItOXeI8MuH4m\n\t5fe+LOD7HH20g==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=EHCmUYrMeziJ2VvmMELUSq2kmBO/F1R8kIswVwQE1U0=;\n\tb=O8cVnwNEJi1wYfND7ZiyEsJ7bTz0zf7lDS4pLaA+fDe68uY67AhR2ofJVRnQu5s1f+\n\tPcDEAjsE+4TEJ16GNM7sMTNz/Nb90SCMKc1EaOvl3/ad7knMyp9EBsOEvwCI8rrSCsvi\n\tzJTHw7SQQzpkUoInK1mGgLU11jSO09MurHWA8VMNC63c4uk9Kh1x2a50p2GuzDNQd6Bs\n\tqBJCUIDjH8DrTLsy0JkUYEu40S7ngjmyvsRqmzha1KT1yZfyWvPTMqsNRovIimHt6QZA\n\tuSx81842jyaDCISWY5z9o04LtLMRNu+Ed6aKDUxdqijxnJUOAZ9BJYHEbcBv8y04LgoC\n\tnahw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"O8cVnwNE\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=EHCmUYrMeziJ2VvmMELUSq2kmBO/F1R8kIswVwQE1U0=;\n\tb=rn6XRcj6xS2BF5iHNnIp/+G17JFqp8bJe/QxdcZoIYKIQkk4nafSyWTI8MBFxWO49g\n\tIxxlg6DXg1tRA9DaHs+8Omq55I1kUje+oinVBmKjhBo7/Ko8aE8poZ4bevBjIAfbVa81\n\t3GVKdD7mpcW2cKkgHDx4ScnFPf5rdKUbRGAhtq7bfZiIL0wLdYVm225nVLq66Vqf6xm9\n\tGDME1AdiaDO3yn16MRg3wZLCY4o9ERSGOFSUfetUXmxPSVCbXfFVsJjU/0Zmn4C2QokS\n\tK+fzN1QwPeaIMw1hmBqaOLwMdCEiemcQ52LDtW8k6u+DnGcgJz2rdlhw1YlKa5GZpknp\n\tfCiQ==","X-Gm-Message-State":"AOAM530uPpjnmWSwNbj8f6d9fApVzNtoPMcQ8J06+KkPhsoik5hS9my+\n\ts2W01nyjV9ws1XdjT1fx2BGl59jGQGPJRw==","X-Google-Smtp-Source":"ABdhPJy73seyr7/IoH8Z4XCAZ8e3Z1O0cPuNtEIsRBlRz/du9Msrw7A7XXkggFkAw8UrH76vJrxvhA==","X-Received":"by 2002:a05:600c:1d9d:b0:397:3dc1:5249 with SMTP id\n\tp29-20020a05600c1d9d00b003973dc15249mr428702wms.144.1653050963994; \n\tFri, 20 May 2022 05:49:23 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 20 May 2022 13:49:19 +0100","Message-Id":"<20220520124919.2873559-1-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.34.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH] pipeline: raspberrypi: Fix possible null\n\tdereference","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":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The freeBuffers() cleanup code calls into the IPA to unmap and free shared\nbuffers. However, this function could be called before the IPA has opened (via\nregisterCamera()), causing a segmentation fault. Fix this by guarding against\ncalling the IPA if it has not been opened.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 10 ++++++----\n 1 file changed, 6 insertions(+), 4 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 2636acb758b7..26cd4e5f2b99 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -1484,10 +1484,12 @@ void PipelineHandlerRPi::mapBuffers(Camera *camera, const RPi::BufferMap &buffer\n \n void RPiCameraData::freeBuffers()\n {\n-\t/* Copy the buffer ids from the unordered_set to a vector to pass to the IPA. */\n-\tstd::vector<unsigned int> ipaBuffers(ipaBuffers_.begin(), ipaBuffers_.end());\n-\tipa_->unmapBuffers(ipaBuffers);\n-\tipaBuffers_.clear();\n+\tif (ipa_) {\n+\t\t/* Copy the buffer ids from the unordered_set to a vector to pass to the IPA. */\n+\t\tstd::vector<unsigned int> ipaBuffers(ipaBuffers_.begin(), ipaBuffers_.end());\n+\t\tipa_->unmapBuffers(ipaBuffers);\n+\t\tipaBuffers_.clear();\n+\t}\n \n \tfor (auto const stream : streams_)\n \t\tstream->releaseBuffers();\n","prefixes":["libcamera-devel"]}