From patchwork Mon Apr 13 10:46:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 3431 Return-Path: Received: from o1.f.az.sendgrid.net (o1.f.az.sendgrid.net [208.117.55.132]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9D20062826 for ; Mon, 13 Apr 2020 12:46:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=uajain.com header.i=@uajain.com header.b="e/3gpEAy"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uajain.com; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=s1; bh=Qtp/cDrwBACdJFlkVAHi6B001l4L/ErjvF4T5OKrb7Q=; b=e/3gpEAy0VPsDPJmM1xXwB2WUjMJMd/PzZdJRvgeeszNSFuqPoOd+7ZK7ONbLv/+UqpL v0oLOKGp3c2M2vuyCa8RvnPYq6UImlijTFe1H6wwT3o95FwpLv21vw+Ap23AEj1tM2/qLT 2N6tjHIgvKqfSJ6sdRyDKyehgLbWiGgjw= Received: by filterdrecv-p3iad2-8ddf98858-w5zgs with SMTP id filterdrecv-p3iad2-8ddf98858-w5zgs-17-5E94431D-1 2020-04-13 10:46:53.157713672 +0000 UTC m=+1589967.452041277 Received: from mail.uajain.com (unknown) by ismtpd0001p1hnd1.sendgrid.net (SG) with ESMTP id yqI_hkVRRvu_j8y6qNYx2A Mon, 13 Apr 2020 10:46:52.812 +0000 (UTC) From: Umang Jain Date: Mon, 13 Apr 2020 10:46:53 +0000 (UTC) Message-Id: <20200413104631.12276-3-email@uajain.com> In-Reply-To: <20200413104631.12276-1-email@uajain.com> References: <20200413104631.12276-1-email@uajain.com> Mime-Version: 1.0 X-SG-EID: 1Q40EQ7YGir8a9gjSIAdTjhngY657NMk9ckeo4dbHZDiOpywc/L3L9rFqlwE4KPcOiinPhbAFGEz1ue/PLGCvOLaxg0kHovbGbOOssNurM64hYKBwWjcYm5ttZtha3r5C57EH5JF3RbbqdsmHlXRa1Y257LaASFxm2dGkkLbhERkfSxNyQPH6xTsITsDlVrzMBrkn65JdU46YT4iX0jxATN/jqYf/7CmLbBNSi++ZscBc3WYtduW6hHx40fFjFboMRp9hT8UZZc81Qcpt3yWeQ== To: libcamera-devel@lists.libcamera.org Subject: [libcamera-devel] [PATCH 2/4] test: ipc: unixsocket: Close open fds on error paths 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: , X-List-Received-Date: Mon, 13 Apr 2020 10:46:55 -0000 Pointed out by Coverity DefectId=279052 Signed-off-by: Umang Jain --- test/ipc/unixsocket.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/ipc/unixsocket.cpp b/test/ipc/unixsocket.cpp index 5348f35..4fc6606 100644 --- a/test/ipc/unixsocket.cpp +++ b/test/ipc/unixsocket.cpp @@ -470,8 +470,10 @@ private: int size = 0; for (unsigned int i = 0; i < num; i++) { int clone = dup(fd); - if (clone < 0) + if (clone < 0) { + close(fd); return clone; + } size += calculateLength(clone); message->fds.push_back(clone);