Fix wrong close for negative file descriptor
authorDongwoo Lee <dwoo08.lee@samsung.com>
Wed, 9 May 2018 06:21:34 +0000 (15:21 +0900)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Fri, 18 May 2018 03:54:40 +0000 (12:54 +0900)
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 <sw0312.kim@samsung.com>
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
libthor/thor_raw_file.c

index e357c68e3075671521d5607109df857fcc37ba9e..fa02f28e6fd9b461ca6d1abdf3687e542afdb8f6 100644 (file)
@@ -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;
 }