[libcamera-devel,v2,1/4] test: ipc: unixsocket: Close open fds on error paths

Message ID 20200515124245.18040-2-email@uajain.com
State Accepted
Headers show
Series
  • Coverity scan fixes
Related show

Commit Message

Umang Jain May 15, 2020, 12:42 p.m. UTC
Pointed out by Coverity DefectId=279099

Signed-off-by: Umang Jain <email@uajain.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 test/ipc/unixsocket.cpp | 2 ++
 1 file changed, 2 insertions(+)

Patch

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;
 					}