summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/buflib.c2
-rw-r--r--firmware/common/dircache.c8
-rw-r--r--firmware/common/zip.c20
-rw-r--r--firmware/font.c3
-rw-r--r--firmware/linuxboot.c3
-rw-r--r--firmware/target/mips/ingenic_x1000/installer-x1000.c3
-rw-r--r--firmware/usbstack/usb_storage.c3
7 files changed, 16 insertions, 26 deletions
diff --git a/firmware/buflib.c b/firmware/buflib.c
index 7263f1b95d..3130bc960c 100644
--- a/firmware/buflib.c
+++ b/firmware/buflib.c
@@ -820,6 +820,8 @@ find_block_before(struct buflib_context *ctx, union buflib_data* block,
820int 820int
821buflib_free(struct buflib_context *ctx, int handle_num) 821buflib_free(struct buflib_context *ctx, int handle_num)
822{ 822{
823 if (handle_num <= 0) /* invalid or already free */
824 return handle_num;
823 union buflib_data *handle = ctx->handle_table - handle_num, 825 union buflib_data *handle = ctx->handle_table - handle_num,
824 *freed_block = handle_to_block(ctx, handle_num), 826 *freed_block = handle_to_block(ctx, handle_num),
825 *block, *next_block; 827 *block, *next_block;
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c
index 7a84b761a0..8917b3348e 100644
--- a/firmware/common/dircache.c
+++ b/firmware/common/dircache.c
@@ -1963,8 +1963,7 @@ static int prepare_build(bool *realloced)
1963 int handle = reset_buffer(); 1963 int handle = reset_buffer();
1964 dircache_unlock(); 1964 dircache_unlock();
1965 1965
1966 if (handle > 0) 1966 core_free(handle);
1967 core_free(handle);
1968 1967
1969 handle = alloc_cache(size); 1968 handle = alloc_cache(size);
1970 1969
@@ -2164,8 +2163,7 @@ static void dircache_suspend_internal(bool freeit)
2164 2163
2165 dircache_unlock(); 2164 dircache_unlock();
2166 2165
2167 if (handle > 0) 2166 core_free(handle);
2168 core_free(handle);
2169 2167
2170 thread_wait(thread_id); 2168 thread_wait(thread_id);
2171 2169
@@ -3179,7 +3177,7 @@ error:
3179 dircache_unlock(); 3177 dircache_unlock();
3180 3178
3181error_nolock: 3179error_nolock:
3182 if (rc < 0 && handle > 0) 3180 if (rc < 0)
3183 core_free(handle); 3181 core_free(handle);
3184 3182
3185 if (fd >= 0) 3183 if (fd >= 0)
diff --git a/firmware/common/zip.c b/firmware/common/zip.c
index 36b90a9223..22c6226e3b 100644
--- a/firmware/common/zip.c
+++ b/firmware/common/zip.c
@@ -237,8 +237,7 @@ static int zip_read_ed(struct zip* z) {
237 rv = 0; 237 rv = 0;
238 238
239bail: 239bail:
240 if (mem_handle >= 0) 240 core_free(mem_handle);
241 core_free(mem_handle);
242 return rv; 241 return rv;
243} 242}
244 243
@@ -337,10 +336,9 @@ static int zip_read_cd(struct zip* z, bool use_cb) {
337 rv = 0; 336 rv = 0;
338 337
339bail: 338bail:
340 if (rv != 0 && cds_handle >= 0) 339 if (rv != 0)
341 core_free(cds_handle); 340 core_free(cds_handle);
342 if (mem_handle >= 0) 341 core_free(mem_handle);
343 core_free(mem_handle);
344 return rv; 342 return rv;
345} 343}
346 344
@@ -497,8 +495,7 @@ static int zip_read_entries(struct zip* z) {
497 rv = 0; 495 rv = 0;
498 496
499bail: 497bail:
500 if (mem_handle >= 0) 498 core_free(mem_handle);
501 core_free(mem_handle);
502 return rv; 499 return rv;
503} 500}
504 501
@@ -754,10 +751,8 @@ struct zip* zip_open(const char* name, bool try_mem) {
754bail: 751bail:
755 if (file >= 0) 752 if (file >= 0)
756 close(file); 753 close(file);
757 if (mem_handle >= 0) 754 core_free(mem_handle);
758 core_free(mem_handle); 755 core_free(zip_handle);
759 if (zip_handle >= 0)
760 core_free(zip_handle);
761 return NULL; 756 return NULL;
762} 757}
763 758
@@ -875,8 +870,7 @@ void zip_close(struct zip* z) {
875 870
876 z->close(z); 871 z->close(z);
877 872
878 if (z->cds_handle >= 0) 873 core_free(z->cds_handle);
879 core_free(z->cds_handle);
880 874
881 core_free(z->zip_handle); 875 core_free(z->zip_handle);
882} 876}
diff --git a/firmware/font.c b/firmware/font.c
index b8fa1c537f..724cb84d57 100644
--- a/firmware/font.c
+++ b/firmware/font.c
@@ -604,8 +604,7 @@ void font_unload(int font_id)
604 glyph_cache_save(font_id); 604 glyph_cache_save(font_id);
605 close(pf->fd); 605 close(pf->fd);
606 } 606 }
607 if (handle > 0) 607 core_free(handle);
608 core_free(handle);
609 buflib_allocations[font_id] = -1; 608 buflib_allocations[font_id] = -1;
610 609
611 } 610 }
diff --git a/firmware/linuxboot.c b/firmware/linuxboot.c
index f9732f6ace..419044b5a9 100644
--- a/firmware/linuxboot.c
+++ b/firmware/linuxboot.c
@@ -221,8 +221,7 @@ int uimage_load(struct uimage_header* uh, size_t* out_size,
221 ret = 0; 221 ret = 0;
222 222
223 err: 223 err:
224 if(state_h > 0) 224 core_free(state_h);
225 core_free(state_h);
226 if(out_h > 0) { 225 if(out_h > 0) {
227 if(ret == 0) 226 if(ret == 0)
228 ret = out_h; 227 ret = out_h;
diff --git a/firmware/target/mips/ingenic_x1000/installer-x1000.c b/firmware/target/mips/ingenic_x1000/installer-x1000.c
index 48850f8a62..ef5bbcd66a 100644
--- a/firmware/target/mips/ingenic_x1000/installer-x1000.c
+++ b/firmware/target/mips/ingenic_x1000/installer-x1000.c
@@ -178,8 +178,7 @@ static void updater_cleanup(struct updater* u)
178 if(u->tar && mtar_is_open(u->tar)) 178 if(u->tar && mtar_is_open(u->tar))
179 mtar_close(u->tar); 179 mtar_close(u->tar);
180 180
181 if(u->buf_hnd >= 0) 181 core_free(u->buf_hnd);
182 core_free(u->buf_hnd);
183 182
184 if(u->ndrv) { 183 if(u->ndrv) {
185 nand_close(u->ndrv); 184 nand_close(u->ndrv);
diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c
index eb82f72eae..08b1f0b7e7 100644
--- a/firmware/usbstack/usb_storage.c
+++ b/firmware/usbstack/usb_storage.c
@@ -481,8 +481,7 @@ void usb_storage_init_connection(void)
481 481
482void usb_storage_disconnect(void) 482void usb_storage_disconnect(void)
483{ 483{
484 if (usb_handle > 0) 484 usb_handle = core_free(usb_handle);
485 usb_handle = core_free(usb_handle);
486} 485}
487 486
488/* called by usb_core_transfer_complete() */ 487/* called by usb_core_transfer_complete() */