From patchwork Tue Apr 16 22:08:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1018 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 6D86360DCC for ; Wed, 17 Apr 2019 00:08:54 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1347BE2 for ; Wed, 17 Apr 2019 00:08:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1555452534; bh=a5p2WN0SdnqNVGvtj5mUdm1cWRoe34iGSLYcw0Rw86A=; h=From:To:Subject:Date:In-Reply-To:References:From; b=rOuHG4CRB6qsN4N574shsp7RIVUbu+WN1qev+EdJ7eteJLV+8ZinMkZCIJGoZoSr3 HYrqr4PvOLlV87OoOr+e1ezZbAYEk1369Xz/68JSUHkv8qFbFOGdaQvQRFPTW7wo6x HBV6OlyLzm/y2Opjrofk2AtkyY52pTuv3Bjecw8I= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Wed, 17 Apr 2019 01:08:35 +0300 Message-Id: <20190416220839.1577-10-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190416220839.1577-1-laurent.pinchart@ideasonboard.com> References: <20190416220839.1577-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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: Tue, 16 Apr 2019 22:08:55 -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 *