From 1ec0490922ecb0a824a8c705f7f0091f7eefb46d Mon Sep 17 00:00:00 2001 From: Dongwoo Lee Date: Wed, 9 May 2018 15:21:34 +0900 Subject: Fix wrong close for negative file descriptor There is an issue which negative file descriptor can be attempt to close in static analysis tool result. This patch fixes to skip close on that case. Change-Id: Ic68803bc96ab6e3737d1bcc4779b8e3c58c7ef71 Signed-off-by: Seung-Woo Kim Signed-off-by: Dongwoo Lee --- libthor/thor_raw_file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libthor/thor_raw_file.c b/libthor/thor_raw_file.c index e357c68..fa02f28 100644 --- a/libthor/thor_raw_file.c +++ b/libthor/thor_raw_file.c @@ -100,7 +100,7 @@ int t_file_get_data_src(const char *path, struct thor_data_src **data) ret = open(path, O_RDONLY); if (ret < 0) - goto close_file; + goto free_data; fdata->fd = ret; @@ -138,6 +138,7 @@ int t_file_get_data_src(const char *path, struct thor_data_src **data) close_file: close(ret); +free_data: free(fdata); return -EINVAL; } -- cgit v1.2.3