{"id":20820,"url":"https://patchwork.libcamera.org/api/patches/20820/?format=json","web_url":"https://patchwork.libcamera.org/patch/20820/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20240807134950.2458614-1-kieran.bingham@ideasonboard.com>","date":"2024-08-07T13:49:50","name":"[v2] libcamera: udev: Catch udev notification errors","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"d0447f469b94aee699cab184bad44b06e641e2d4","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/20820/mbox/","series":[{"id":4495,"url":"https://patchwork.libcamera.org/api/series/4495/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4495","date":"2024-08-07T13:49:50","name":"[v2] libcamera: udev: Catch udev notification errors","version":2,"mbox":"https://patchwork.libcamera.org/series/4495/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/20820/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/20820/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 A2169BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  7 Aug 2024 13:49:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4FDCB63394;\n\tWed,  7 Aug 2024 15:49:56 +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 EE41C6337F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  7 Aug 2024 15:49:54 +0200 (CEST)","from Monstersaurus.tail69b4.ts.net\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 2214D96C;\n\tWed,  7 Aug 2024 15:49:02 +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=\"gz4VbUi6\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1723038542;\n\tbh=87qaTeZ4K0gRbq7cv67GpMRYcN+hw5vC4T128nalHfw=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=gz4VbUi6I2Nfu/cDwo/6clTEfZytEa+W4BIRyRFZFhaD9D2gX4Ivpj7SSMDDWz11s\n\tfzBMTFVsMDy/yRIM6wR7Ulia1BpVXpEo/I+nWYE6Fd3zgukdIyJ4d+RV1v6X0cnXGG\n\tZiCueegF1vsi2NafWD/pAnzWOF9KAks/Pxz5X6Ig=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tStefan Klug <stefan.klug@ideasonboard.com>","Subject":"[PATCH v2] libcamera: udev: Catch udev notification errors","Date":"Wed,  7 Aug 2024 14:49:50 +0100","Message-Id":"<20240807134950.2458614-1-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.34.1","MIME-Version":"1.0","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":"The udev_monitor_receive_device() can return NULL on an error as\ndetailed in the man pages for the function.\n\nThe udevNotify() handler in the DeviceEnumeratorUdev directly uses the\nreturn value of udev_monitor_receive_device() in successive calls to\nprocess the event without having first checked the udev_device.\n\nEnsure we identify, and handle events where the udev_device can not be\nreturned successfully.\n\nBug: https://bugs.libcamera.org/show_bug.cgi?id=230\nReviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n---\nv2:\n - Report strerror based on errno from the udev_monitor_receive_device()\n   call.\n\n src/libcamera/device_enumerator_udev.cpp | 8 ++++++++\n 1 file changed, 8 insertions(+)","diff":"diff --git a/src/libcamera/device_enumerator_udev.cpp b/src/libcamera/device_enumerator_udev.cpp\nindex 01c70b6daa82..53eeb772d900 100644\n--- a/src/libcamera/device_enumerator_udev.cpp\n+++ b/src/libcamera/device_enumerator_udev.cpp\n@@ -332,6 +332,14 @@ int DeviceEnumeratorUdev::addV4L2Device(dev_t devnum)\n void DeviceEnumeratorUdev::udevNotify()\n {\n \tstruct udev_device *dev = udev_monitor_receive_device(monitor_);\n+\tif (!dev) {\n+\t\tint error = errno;\n+\t\tLOG(DeviceEnumerator, Warning)\n+\t\t\t<< \"Ignoring notfication received without a device: \"\n+\t\t\t<< strerror(error);\n+\t\treturn;\n+\t}\n+\n \tstd::string_view action(udev_device_get_action(dev));\n \tstd::string_view deviceNode(udev_device_get_devnode(dev));\n \n","prefixes":["v2"]}