From patchwork Mon Mar 4 23:25:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 701 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 667B6611A2 for ; Tue, 5 Mar 2019 00:25:37 +0100 (CET) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E4C34322; Tue, 5 Mar 2019 00:25:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1551741937; bh=UZhZ6VNetcFDXQvCB2eHdc2R0StuH2/jONUwm+yGUlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YaDxY1cHdggoxRbCCCgPbsBFitKnl5HWdlOn1Zo48yoiAO4ZZZjSb7QvkdHh663Ks GczEsZbcNLwt+4RxY3deDPy7UFFjWOL0A2Gi1nvXbB+TW1TkBNzl5huf23WHj3cBdA ix0Tx1AAk7VnGxKNE0l9QifJYXwOQKnOoeVlaupA= From: Kieran Bingham To: LibCamera Devel Date: Mon, 4 Mar 2019 23:25:29 +0000 Message-Id: <20190304232530.4427-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190304232530.4427-1-kieran.bingham@ideasonboard.com> References: <20190304232530.4427-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] libcamera: v4l2_device: Close Plane dmabuf fd X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Mar 2019 23:25:38 -0000 When constructing a Plane, the exported buffer provides a dmabuf handle which is set to the Plane object. This action duplicates the handle for internal storage, and the original fd is not used and needs to be closed. Close the handle, ensuring that the resources can be correctly managed. Fixes: 771befc6dc0e ("libcamera: v4l2_device: Request buffers from the device") Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/libcamera/v4l2_device.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 0cd9f4b8e178..a88a5f5ff036 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -676,6 +676,7 @@ int V4L2Device::createPlane(Buffer *buffer, unsigned int planeIndex, buffer->planes().emplace_back(); Plane &plane = buffer->planes().back(); plane.setDmabuf(expbuf.fd, length); + ::close(expbuf.fd); return 0; }