Patch Detail
Show a patch.
GET /api/patches/14156/?format=api
{ "id": 14156, "url": "https://patchwork.libcamera.org/api/patches/14156/?format=api", "web_url": "https://patchwork.libcamera.org/patch/14156/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/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": "<20211014233351.23092-1-kpoduval@gmail.com>", "date": "2021-10-14T23:33:51", "name": "[libcamera-devel] libcamera: v4l2_videodevice: close dmabuf fd", "commit_ref": null, "pull_url": null, "state": "rejected", "archived": false, "hash": "ac40400b81b5e0a2a5a9bf14054bc39e580aa4bb", "submitter": { "id": 100, "url": "https://patchwork.libcamera.org/api/people/100/?format=api", "name": "Karthik Poduval", "email": "kpoduval@gmail.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/14156/mbox/", "series": [ { "id": 2631, "url": "https://patchwork.libcamera.org/api/series/2631/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2631", "date": "2021-10-14T23:33:51", "name": "[libcamera-devel] libcamera: v4l2_videodevice: close dmabuf fd", "version": 1, "mbox": "https://patchwork.libcamera.org/series/2631/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/14156/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/14156/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 6D71AC323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Oct 2021 08:42:25 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D1E0E68F4F;\n\tFri, 15 Oct 2021 10:42:24 +0200 (CEST)", "from smtp-fw-6001.amazon.com (smtp-fw-6001.amazon.com\n\t[52.95.48.154])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C370B60501\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Oct 2021 01:34:13 +0200 (CEST)", "from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO\n\temail-inbound-relay-pdx-2a-5feb294a.us-west-2.amazon.com)\n\t([10.43.8.6]) by smtp-border-fw-6001.iad6.amazon.com with ESMTP;\n\t14 Oct 2021 23:34:12 +0000", "from EX13MTAUWB001.ant.amazon.com\n\t(pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198])\n\tby email-inbound-relay-pdx-2a-5feb294a.us-west-2.amazon.com (Postfix)\n\twith\n\tESMTPS id 752E680B43 for <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 Oct 2021 23:34:11 +0000 (UTC)", "from EX13D07UWB001.ant.amazon.com (10.43.161.238) by\n\tEX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP\n\tServer (TLS) id 15.0.1497.23; Thu, 14 Oct 2021 23:34:11 +0000", "from EX13MTAUEE002.ant.amazon.com (10.43.62.24) by\n\tEX13D07UWB001.ant.amazon.com (10.43.161.238) with Microsoft SMTP\n\tServer (TLS) id 15.0.1497.24; Thu, 14 Oct 2021 23:34:11 +0000", "from dev-dsk-kpoduval-2c-618debf1.us-west-2.amazon.com\n\t(172.23.136.85) by mail-relay.amazon.com (10.43.62.224) with\n\tMicrosoft SMTP Server id 15.0.1497.24 via Frontend Transport;\n\tThu, 14 Oct 2021 23:34:10 +0000", "by dev-dsk-kpoduval-2c-618debf1.us-west-2.amazon.com (Postfix,\n\tfrom userid 293312)\n\tid 0618B429F3; Thu, 14 Oct 2021 23:34:10 +0000 (UTC)" ], "X-IronPort-AV": "E=Sophos;i=\"5.85,374,1624320000\"; d=\"scan'208\";a=\"149323119\"", "From": "Karthik Poduval <kpoduval@gmail.com>", "To": "<libcamera-devel@lists.libcamera.org>", "Date": "Thu, 14 Oct 2021 23:33:51 +0000", "Message-ID": "<20211014233351.23092-1-kpoduval@gmail.com>", "X-Mailer": "git-send-email 2.32.0", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Content-Type": "text/plain", "X-Mailman-Approved-At": "Fri, 15 Oct 2021 10:42:23 +0200", "Subject": "[libcamera-devel] [PATCH] libcamera: v4l2_videodevice: close dmabuf\n\tfd", "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": "From: Karthik Poduval <kpoduval@lab126.com>\n\nThe dmabuf fd that comes from V4L2_EXPBUF is passed to FileDescriptor\nwhich makes a dup of the fd and stores it. However the original fd\nisn't closed and this causes the vb2's buf reference count to remain at\n3 (one for kernel, one for V4L2_EXPBUF and one for the dup fd by File\nDescriptor). When requestbufs is called with zero count, it unable to\nfree the buffer as the refcount is still 2. After FileDecriptor dup the\nfd the original fd must be closed so that the buf refcount is maintained\nproperly by vb2.\n\nSigned-off-by: Karthik Poduval <kpoduval@lab126.com>\n---\n src/libcamera/v4l2_videodevice.cpp | 10 +++++++++-\n 1 file changed, 9 insertions(+), 1 deletion(-)", "diff": "diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex ba5f88cd..8c85da22 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -1384,6 +1384,7 @@ FileDescriptor V4L2VideoDevice::exportDmabufFd(unsigned int index,\n {\n \tstruct v4l2_exportbuffer expbuf = {};\n \tint ret;\n+\tFileDescriptor fd;\n \n \texpbuf.type = bufferType_;\n \texpbuf.index = index;\n@@ -1397,7 +1398,14 @@ FileDescriptor V4L2VideoDevice::exportDmabufFd(unsigned int index,\n \t\treturn FileDescriptor();\n \t}\n \n-\treturn FileDescriptor(std::move(expbuf.fd));\n+\tfd = FileDescriptor(std::move(expbuf.fd));\n+\t/*\n+\t * since FileDesciptor makes a dup of the fd, original fd must be\n+\t * closed or else driver considers it as an orphaned buffer (due to\n+\t * additional buffer refcount) thus causing a frame buffer leak\n+\t */\n+\t::close(expbuf.fd);\n+\treturn fd;\n }\n \n /**\n", "prefixes": [ "libcamera-devel" ] }