From patchwork Thu Apr 18 14:14:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1056 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 30E5C60DDC for ; Thu, 18 Apr 2019 16:14:58 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AFD2B9A7 for ; Thu, 18 Apr 2019 16:14:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1555596897; bh=/HOFiTfjXrNuaK6WbexcRsw61u3GR7weSKjD8dBPiYY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Q35yhMVXa0IyvyMoLlkJ2hTd1Cwff2b1cqa+o7FQTb1vNDnwUrbGZyaoP/shzNSiY wW9IQ5SU+Bf6qCHug0PzDEubB49R67NErGUnI1ZpGfh0Qrien7j0adEwxNsOWd3cpH W+7ukla3x46Y47r3GyroxlwvF75JP802MwVICb0M= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 18 Apr 2019 17:14:33 +0300 Message-Id: <20190418141437.14014-10-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418141437.14014-1-laurent.pinchart@ideasonboard.com> References: <20190418141437.14014-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 09/13] libcamera: v4l2_subdevice: Close subdevice when destroyed 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: Thu, 18 Apr 2019 14:15:00 -0000 Make sure the subdevice file descriptor isn't leaked by closing it when the V4L2Subdevice instance is destroyed. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- src/libcamera/include/v4l2_subdevice.h | 1 + src/libcamera/v4l2_subdevice.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h index c71dce7d8644..e592d67dd043 100644 --- a/src/libcamera/include/v4l2_subdevice.h +++ b/src/libcamera/include/v4l2_subdevice.h @@ -35,6 +35,7 @@ public: explicit V4L2Subdevice(const MediaEntity *entity); V4L2Subdevice(const V4L2Subdevice &) = delete; V4L2Subdevice &operator=(const V4L2Subdevice &) = delete; + ~V4L2Subdevice(); int open(); bool isOpen() const; diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index e34cc1693b46..a03fadfd579e 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -112,6 +112,11 @@ V4L2Subdevice::V4L2Subdevice(const MediaEntity *entity) { } +V4L2Subdevice::~V4L2Subdevice() +{ + close(); +} + /** * \brief Open a V4L2 subdevice *