From patchwork Tue Nov 30 03:38:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14867 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id D2F44C3250 for ; Tue, 30 Nov 2021 03:39:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6375F605C9; Tue, 30 Nov 2021 04:39:10 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="VLzOLZC+"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5C671605C5 for ; Tue, 30 Nov 2021 04:38:53 +0100 (CET) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id F15658F0 for ; Tue, 30 Nov 2021 04:38:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1638243533; bh=HRaDc/H3d+k8FtCEKM4DP3DYdnS5/MmVHIPIqXvhsnQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=VLzOLZC+LQ3y6DpZDamziAObYPkUC6ve4QPMM7helm+k7zXBfFzUYAn8gCGsCja7V pS6oCdT5UThELYE2R9U8DUs44bW2PVF5AZLYBnN00DIsF6bwJqle/ZkBvxQCN3rQ+T W+xvxOCH1Lx1lADVNuNo83GRzWFcWohixxToj2c0= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Tue, 30 Nov 2021 05:38:09 +0200 Message-Id: <20211130033820.18235-12-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211130033820.18235-1-laurent.pinchart@ideasonboard.com> References: <20211130033820.18235-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 11/22] libcamera: ipc_unixsocket: Fix file descriptor leak X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The file descriptor created for the remote side of the socket is passed to the forked process, but never closed. Fix the leak. The fix can be tested by running the unixsocket_ipc unit test under valgrind with `valgrind --track-fds=yes ./test/ipc/unixsocket_ipc`. Signed-off-by: Laurent Pinchart Reviewed-by: Hirokazu Honda Reviewed-by: Jacopo Mondi --- src/libcamera/ipc_pipe_unixsocket.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/ipc_pipe_unixsocket.cpp b/src/libcamera/ipc_pipe_unixsocket.cpp index 65277500ff42..3ef907090131 100644 --- a/src/libcamera/ipc_pipe_unixsocket.cpp +++ b/src/libcamera/ipc_pipe_unixsocket.cpp @@ -38,7 +38,7 @@ IPCPipeUnixSocket::IPCPipeUnixSocket(const char *ipaModulePath, } socket_->readyRead.connect(this, &IPCPipeUnixSocket::readyRead); args.push_back(std::to_string(fd.get())); - fds.push_back(fd.release()); + fds.push_back(fd.get()); proc_ = std::make_unique(); int ret = proc_->start(ipaProxyWorkerPath, args, fds);