From patchwork Tue Jan 8 14:46:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 179 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 A92EE60B2E for ; Tue, 8 Jan 2019 15:45:16 +0100 (CET) Received: from avalon.bb.dnainternet.fi (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 246B3586 for ; Tue, 8 Jan 2019 15:45:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1546958716; bh=1VXAPpRUEant/goqATXdnurosvpn6lLr8rJrQghbfmU=; h=From:To:Subject:Date:From; b=ihAmfWtVe7hZdyIEyBJRLM09m1Fr3b2AmEpgetWhqJ5CCmAXhJIqSDhHjVXqLCf8z 3WXa7jN//G/E+r2YsfO/vhDBASqTwpIvVyHUm7LbB5jpQEAcp5VEoq3fQw69waFZpy shTWjv340+59zxmM/lmQlrxfGxLkv3nYgpyhR5mU= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Tue, 8 Jan 2019 16:46:21 +0200 Message-Id: <20190108144621.10546-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: device_enumerator: Fix memory leak in error path 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, 08 Jan 2019 14:45:16 -0000 The DeviceEnumerator::create() function allocates a DeviceEnumeratorUdev and fails to delete it in the error path, causing a memory leak. Fix it. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/libcamera/device_enumerator.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp index f1d016db64a0..0d18e75525af 100644 --- a/src/libcamera/device_enumerator.cpp +++ b/src/libcamera/device_enumerator.cpp @@ -140,6 +140,8 @@ DeviceEnumerator *DeviceEnumerator::create() if (!enumerator->init()) return enumerator; + delete enumerator; + /* * Either udev is not available or udev initialization failed. Fall back * on the sysfs enumerator.