lib: fwts_memorymap: fix resource leak on dir on error return path
diff mbox series

Message ID 20200113114812.166284-1-colin.king@canonical.com
State Accepted
Headers show
Series
  • lib: fwts_memorymap: fix resource leak on dir on error return path
Related show

Commit Message

Colin King Jan. 13, 2020, 11:48 a.m. UTC
From: Colin Ian King <colin.king@canonical.com>

The error return path is leaking object dir, call closedir to fix
this leak.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_memorymap.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Alex Hung Jan. 13, 2020, 6:13 p.m. UTC | #1
On 2020-01-13 4:48 a.m., Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The error return path is leaking object dir, call closedir to fix
> this leak.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_memorymap.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/lib/src/fwts_memorymap.c b/src/lib/src/fwts_memorymap.c
> index 241b552e..038ccd63 100644
> --- a/src/lib/src/fwts_memorymap.c
> +++ b/src/lib/src/fwts_memorymap.c
> @@ -315,6 +315,7 @@ fwts_list *fwts_memory_map_table_load(fwts_framework *fw)
>  			entry = fwts_memory_map_table_read_entry(directory->d_name);
>  			if (!entry) {
>  				fwts_memory_map_table_free(memory_map_list);
> +				(void)closedir(dir);
>  				return NULL;
>  			}
>  			fwts_list_add_ordered(memory_map_list, entry, fwts_fwts_memory_map_entry_compare);
> 

Acked-by: Alex Hung <alex.hung@canonical.com>
ivanhu Jan. 14, 2020, 4:21 a.m. UTC | #2
On 1/13/20 7:48 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The error return path is leaking object dir, call closedir to fix
> this leak.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_memorymap.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/lib/src/fwts_memorymap.c b/src/lib/src/fwts_memorymap.c
> index 241b552e..038ccd63 100644
> --- a/src/lib/src/fwts_memorymap.c
> +++ b/src/lib/src/fwts_memorymap.c
> @@ -315,6 +315,7 @@ fwts_list *fwts_memory_map_table_load(fwts_framework *fw)
>  			entry = fwts_memory_map_table_read_entry(directory->d_name);
>  			if (!entry) {
>  				fwts_memory_map_table_free(memory_map_list);
> +				(void)closedir(dir);
>  				return NULL;
>  			}
>  			fwts_list_add_ordered(memory_map_list, entry, fwts_fwts_memory_map_entry_compare);
> 


Acked-by: Ivan Hu <ivan.hu@canonical.com>

Patch
diff mbox series

diff --git a/src/lib/src/fwts_memorymap.c b/src/lib/src/fwts_memorymap.c
index 241b552e..038ccd63 100644
--- a/src/lib/src/fwts_memorymap.c
+++ b/src/lib/src/fwts_memorymap.c
@@ -315,6 +315,7 @@  fwts_list *fwts_memory_map_table_load(fwts_framework *fw)
 			entry = fwts_memory_map_table_read_entry(directory->d_name);
 			if (!entry) {
 				fwts_memory_map_table_free(memory_map_list);
+				(void)closedir(dir);
 				return NULL;
 			}
 			fwts_list_add_ordered(memory_map_list, entry, fwts_fwts_memory_map_entry_compare);