Show a patch.

GET /api/patches/3794/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 3794,
    "url": "https://patchwork.libcamera.org/api/patches/3794/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/3794/",
    "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": "<20200514084003.16948-1-naush@raspberrypi.com>",
    "date": "2020-05-14T08:40:03",
    "name": "[libcamera-devel,v2] libcamera: v4l2_videodevice: Fix dangling file descriptor",
    "commit_ref": "353fc4c223225f32176f9fc35a832d633486aa0d",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "800c05e5c059eaeb92901d58bd5375c0855f0b20",
    "submitter": {
        "id": 34,
        "url": "https://patchwork.libcamera.org/api/people/34/?format=api",
        "name": "Naushir Patuck",
        "email": "naush@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/3794/mbox/",
    "series": [
        {
            "id": 904,
            "url": "https://patchwork.libcamera.org/api/series/904/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=904",
            "date": "2020-05-14T08:40:03",
            "name": "[libcamera-devel,v2] libcamera: v4l2_videodevice: Fix dangling file descriptor",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/904/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/3794/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/3794/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<naush@raspberrypi.com>",
        "Received": [
            "from mail-wr1-x444.google.com (mail-wr1-x444.google.com\n\t[IPv6:2a00:1450:4864:20::444])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AEB4860DE6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 May 2020 10:40:10 +0200 (CEST)",
            "by mail-wr1-x444.google.com with SMTP id l11so2800541wru.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 May 2020 01:40:10 -0700 (PDT)",
            "from naushir-VirtualBox.patuck.local ([88.97.76.4])\n\tby smtp.gmail.com with ESMTPSA id\n\to203sm23337886wme.12.2020.05.14.01.40.09\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 14 May 2020 01:40:09 -0700 (PDT)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"NLsex3Q3\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id;\n\tbh=9T45KgV/DtI1j/9bQO+bF54N9jAoocbfPKibMpLyd68=;\n\tb=NLsex3Q3sQNEKk76ZEkWGLQyzfWO0nqyPxR4ydMqyA586sJzNNFW03rEs7n1GGJwDB\n\t405xOId0ZwIH/c0bCvkS29HXko42nankW8RUG1zaHSNLfYgUycdwLcBUqu/FiB8xaaJ3\n\tyh4gqyXy7e3IrYXS6REARf4heCqk8+KINM3mahb/qnACA7VavuotyrTB193I7fJtk4aK\n\t2H8NVttB7dHOjAzgw5bGYoYgTCq7KjfzWK1ulG2wOMXIGJbsw8uAs2d6JcKIwP0Jr1S1\n\tVqHsmp4OqapKfoiLg4b9B3FJOErXLYQ2gBirj/aM7K776hzUgseIuZHhr8YxEF+upvyD\n\tzGUQ==",
        "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;\n\tbh=9T45KgV/DtI1j/9bQO+bF54N9jAoocbfPKibMpLyd68=;\n\tb=knd4Drs24UYqY1hVieG/HwNJTnolIk+/1AcHztw721+4+r8bv+TANyahaRMWwf0Swv\n\tB6dVun6QiiRA+Xey7gOdonExtmtz7Qi84h2F8ZHTdNuIG2xsr5+T6Hierml2IY1NZ+mb\n\tASs4v3f9p1ClJ8rBbGVR9W9vKbE1C8Da8r3j5oHtzNkeIR8FNODd0WUvBy27GtpaLuQ/\n\tG4k2pG5RXx3P5ihoXMNuygl37DNo0t9s0QzS/FE26j+wIHNi4FOL18mCZ3EMaSHlasCh\n\tOrTzuqenGdOPpAPdnrwprcCIyJNMo/NB7sOa4NEwUiR9tPwICZMl/iDp/eRAKERthu0o\n\tFp+A==",
        "X-Gm-Message-State": "AOAM531umIq3crdRZcGfU2b3DNYvqCA7hJzxFwLomh1h1B/+BCLFqkf4\n\txLZ/jsavJAgOuTZEpWq86m0ntF45JItVhQ==",
        "X-Google-Smtp-Source": "ABdhPJzb2ttwD4JZ15Rz6zF8vLtDMelzRtYG6x0Zt8xXogQutYzY0azrIS1aMxWRv3zCZwNXNt9ydw==",
        "X-Received": "by 2002:adf:a51a:: with SMTP id\n\ti26mr3956114wrb.332.1589445610282; \n\tThu, 14 May 2020 01:40:10 -0700 (PDT)",
        "From": "Naushir Patuck <naush@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 14 May 2020 09:40:03 +0100",
        "Message-Id": "<20200514084003.16948-1-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "Subject": "[libcamera-devel] [PATCH v2] libcamera: v4l2_videodevice: Fix\n\tdangling file descriptor",
        "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>",
        "X-List-Received-Date": "Thu, 14 May 2020 08:40:12 -0000"
    },
    "content": "The FileDescriptor constructor used in V4L2VideoDevice::exportDmabufFd()\ncreates a duplicate of the fd to store in the object. The original\nfd returned by the VIDIOC_EXPBUF ioctl was never closed, and left\ndangling. This would cause out of memory conditions if the camera stream\nwas repeatedly started and stopped.\n\nThis change closes the original fd explicitly, fixing the leak.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/libcamera/v4l2_videodevice.cpp | 9 ++++++++-\n 1 file changed, 8 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex 4b9f8b5c..2f9c1333 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -1276,7 +1276,14 @@ FileDescriptor V4L2VideoDevice::exportDmabufFd(unsigned int index,\n \t\treturn FileDescriptor();\n \t}\n \n-\treturn FileDescriptor(expbuf.fd);\n+\tFileDescriptor fd(expbuf.fd);\n+\t/*\n+\t * FileDescriptor takes a duplicate of fd, so we must close the\n+\t * original here, otherwise it will be left dangling.\n+\t */\n+\t::close(expbuf.fd);\n+\n+\treturn fd;\n }\n \n /**\n",
    "prefixes": [
        "libcamera-devel",
        "v2"
    ]
}