From patchwork Mon Apr 13 10:46:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 3430 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 A0CED6279B for ; Mon, 13 Apr 2020 12:46:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=uajain.com header.i=@uajain.com header.b="yjb5j75B"; 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=Y03Ll6yzLr1iyJPFMtkLojTteG6/i02TnsXQjRnuus8=; b=yjb5j75BBJbv5cQpnEAk/TLQ9J1jQa+Z27gISA2gwBRkLGKnAMByyoo+YHYAK3+ihVUq 1dHeI+f/ZHWlzIN9k6jJe1SNqP4sfo+F4LQvMXOman+5OEm8HpSIR1zxVy6vzxySvBZPn1 8wWU6+E1Fyyk/KeirvEmdxn4Uae4/WSFc= Received: by filterdrecv-p3iad2-8ddf98858-w5zgs with SMTP id filterdrecv-p3iad2-8ddf98858-w5zgs-17-5E94431A-43 2020-04-13 10:46:51.137941207 +0000 UTC m=+1589965.432268828 Received: from mail.uajain.com (unknown) by ismtpd0008p1maa1.sendgrid.net (SG) with ESMTP id rXvBFzRsR9qGz3Ae-Nr7xw Mon, 13 Apr 2020 10:46:50.374 +0000 (UTC) From: Umang Jain Date: Mon, 13 Apr 2020 10:46:51 +0000 (UTC) Message-Id: <20200413104631.12276-2-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/L3L9rFqlwE4KPcIgOyDPOiX995eQdp4XFd3IZu5+c97D8x47w6im9u3eJmzXBdYWObWYD7xrkJRveqCVzi+AY+njAWbDzk+QB8hB1LzWzudFaQ2wEm7/UDmyxHMrmX5lW9n/OeuLDxxnyEqQ/LsPSE9XmZhklGKPC06avxeWc/2vXXY92VUHEhDyxAuUCAX1H16e5XY2Ys21ik6KW7dZwv1P2X9G83Chlprw== To: libcamera-devel@lists.libcamera.org Subject: [libcamera-devel] [PATCH 1/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:53 -0000 Pointed out by Coverity DefectId=279099 Signed-off-by: Umang Jain Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- test/ipc/unixsocket.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/ipc/unixsocket.cpp b/test/ipc/unixsocket.cpp index f53042b..5348f35 100644 --- a/test/ipc/unixsocket.cpp +++ b/test/ipc/unixsocket.cpp @@ -145,6 +145,7 @@ private: if (num < 0) { cerr << "Read failed" << endl; + close(outfd); stop(-EIO); return; } else if (!num) @@ -152,6 +153,7 @@ private: if (write(outfd, buf, num) < 0) { cerr << "Write failed" << endl; + close(outfd); stop(-EIO); return; } 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); 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: 3432 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 4055A62826 for ; Mon, 13 Apr 2020 12:46:55 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=uajain.com header.i=@uajain.com header.b="sOylzT+u"; 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=lN5t0qg8HDzYt647wu399qU8mdOYbLlm40/6lHf9K4M=; b=sOylzT+uQ8DzJXoOXDewWwkkLEbDRQmHP6dxwlVYC6Ib61sPq04JRyQZWdz7RoI7h47D FpXYCkMdpFiMRWzhsLnW8tTShIKdhPnY//TiRRtKST9CitFl28BxjOQrt6SIDXxFwt6vHF j7hmxtDsZJdAz4sZ0GHRJ1oQ5QSUnp7Bs= Received: by filterdrecv-p3iad2-8ddf98858-xn4j7 with SMTP id filterdrecv-p3iad2-8ddf98858-xn4j7-19-5E94431D-4E 2020-04-13 10:46:53.970656372 +0000 UTC m=+1589960.232487496 Received: from mail.uajain.com (unknown) by ismtpd0003p1maa1.sendgrid.net (SG) with ESMTP id pBCBNRobS1WWPUlJ5XCRAQ Mon, 13 Apr 2020 10:46:53.546 +0000 (UTC) From: Umang Jain Date: Mon, 13 Apr 2020 10:46:53 +0000 (UTC) Message-Id: <20200413104631.12276-4-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/L3L9rFqlwE4KPc/mSirh79xX0l6HRHZb2eYA0RzoWaZc/nZ9Udko5MldTi0ZsdsFe5G+ye+/UjefY0wCezfshHodjSd9PWgoKnbrFFFjQtb8Bm8oTEbA1lVfl04A9DeEThI8P04m+SDVdK9RH1x+gGuI+HjwSAO3CUOV6+y4pMN1TEls+C7pevfKRutLTuMGuO1D5zWsJcn9j/dYQztw8mVrqMyoqdNJ1DTA== To: libcamera-devel@lists.libcamera.org Subject: [libcamera-devel] [PATCH 3/4] test: log: log_api: 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=279091 Signed-off-by: Umang Jain --- test/log/log_api.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/log/log_api.cpp b/test/log/log_api.cpp index 33622f8..aeedbf9 100644 --- a/test/log/log_api.cpp +++ b/test/log/log_api.cpp @@ -96,6 +96,7 @@ protected: lseek(fd, 0, SEEK_SET); if (read(fd, buf, sizeof(buf)) < 0) { cerr << "Failed to read tmp log file" << endl; + close(fd); return TestFail; } close(fd); From patchwork Mon Apr 13 10:46:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 3433 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 9E08362826 for ; Mon, 13 Apr 2020 12:46:56 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=uajain.com header.i=@uajain.com header.b="BJsVZW+n"; 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=lnej2EnrhGZdGHi+oYTyOl0lU5e/C29RGqqXEPQUKQ4=; b=BJsVZW+nAX00JqG/p0Soylu4bkZDCA1ImuQjge+hxsFMC7VF8ZIiCMMAc66qELoXKu1c /7X9FoKFjOLBxpBfdc7NghALpJxiDkMFj1IWfDSoStrqmsGgiWSjxj6v9HnLa+ENnqm/S4 o7WcXryy8v+8hTVHiarW1j767ILdhvge4= Received: by filterdrecv-p3iad2-8ddf98858-xm5rk with SMTP id filterdrecv-p3iad2-8ddf98858-xm5rk-18-5E94431F-1C 2020-04-13 10:46:55.560459526 +0000 UTC m=+1513404.540192897 Received: from mail.uajain.com (unknown) by ismtpd0002p1maa1.sendgrid.net (SG) with ESMTP id _MNMZXwcSO-p0tneNjxbog Mon, 13 Apr 2020 10:46:55.158 +0000 (UTC) From: Umang Jain Date: Mon, 13 Apr 2020 10:46:55 +0000 (UTC) Message-Id: <20200413104631.12276-5-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/L3L9rFqlwE4KPc9vLW9W8H4bP+KZ0PPVtun/auY9FtTkZgn/nQf0Y06iNRgTP5yjireSIn9mtcUeX2FiGxxLCfPxkM+JKJEEePO1hLNtYod9v4CjzeDnwqQHQOuZAaQxU7jS6Vv2SWz9OohMnAM4n6r1KPhUtje5DRCAJLjRgSDuje+0ToFImZ35QMxu2Nz6U4OxTLJfGR9hdLIvv1DH9hQ0cyBrCALM/BxQ== To: libcamera-devel@lists.libcamera.org Subject: [libcamera-devel] [PATCH 4/4] test: log: log_process: 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:57 -0000 Pointed out by Coverity DefectId=279097 Signed-off-by: Umang Jain Reviewed-by: Kieran Bingham --- test/log/log_process.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/log/log_process.cpp b/test/log/log_process.cpp index 2df4aa4..88baa27 100644 --- a/test/log/log_process.cpp +++ b/test/log/log_process.cpp @@ -106,6 +106,7 @@ protected: memset(buf, 0, sizeof(buf)); if (read(fd, buf, sizeof(buf)) < 0) { cerr << "Failed to read tmp log file" << endl; + close(fd); return TestFail; } close(fd);