[libcamera-devel,4/4] test: log: log_process: Close open fds on error paths

Message ID 20200413104631.12276-5-email@uajain.com
State Accepted
Headers show
Series
  • Fix resource leaks pointed out by coverity scans
Related show

Commit Message

Umang Jain April 13, 2020, 10:46 a.m. UTC
Pointed out by Coverity DefectId=279097

Signed-off-by: Umang Jain <email@uajain.com>
---
 test/log/log_process.cpp | 1 +
 1 file changed, 1 insertion(+)

Comments

Kieran Bingham April 14, 2020, 11:32 a.m. UTC | #1
Hi Umang

On 13/04/2020 11:46, Umang Jain wrote:
> Pointed out by Coverity DefectId=279097

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> Signed-off-by: Umang Jain <email@uajain.com>
> ---
>  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);
>

Patch

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