From 4108352612bffe2e6d41d0a08c2ba216a70724a8 Mon Sep 17 00:00:00 2001 From: Alin Jerpelea Date: Mon, 20 Nov 2017 10:04:51 +0800 Subject: [PATCH 1/7] libs: libc: math: Fix tanh() math functions --- libs/libc/math/lib_tanh.c | 2 +- libs/libc/math/lib_tanhf.c | 2 +- libs/libc/math/lib_tanhl.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/libc/math/lib_tanh.c b/libs/libc/math/lib_tanh.c index 4cbaf3d7d50bf..85dce6df5f6ee 100644 --- a/libs/libc/math/lib_tanh.c +++ b/libs/libc/math/lib_tanh.c @@ -44,6 +44,6 @@ double tanh(double x) double x0 = exp(x); double x1 = 1.0 / x0; - return ((x0 + x1) / (x0 - x1)); + return ((x0 - x1) / (x0 + x1)); } #endif diff --git a/libs/libc/math/lib_tanhf.c b/libs/libc/math/lib_tanhf.c index e3df3774b7e3d..8db236abf8fe4 100644 --- a/libs/libc/math/lib_tanhf.c +++ b/libs/libc/math/lib_tanhf.c @@ -40,5 +40,5 @@ float tanhf(float x) float x0 = expf(x); float x1 = 1.0F / x0; - return ((x0 + x1) / (x0 - x1)); + return ((x0 - x1) / (x0 + x1)); } diff --git a/libs/libc/math/lib_tanhl.c b/libs/libc/math/lib_tanhl.c index 4303ea178e82e..a03c000ef7d0a 100644 --- a/libs/libc/math/lib_tanhl.c +++ b/libs/libc/math/lib_tanhl.c @@ -44,6 +44,6 @@ long double tanhl(long double x) long double x0 = exp(x); long double x1 = 1.0 / x0; - return ((x0 + x1) / (x0 - x1)); + return ((x0 - x1) / (x0 + x1)); } #endif From 6de3155b4b6e8628f0de71f03a555481fc8b6862 Mon Sep 17 00:00:00 2001 From: Alin Jerpelea Date: Fri, 22 Jun 2018 12:08:14 +0900 Subject: [PATCH 2/7] binfmt: libelf: Fix fd not closed on error --- binfmt/libelf/libelf_init.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/binfmt/libelf/libelf_init.c b/binfmt/libelf/libelf_init.c index 97be242197f10..11223f75e36cd 100644 --- a/binfmt/libelf/libelf_init.c +++ b/binfmt/libelf/libelf_init.c @@ -176,6 +176,7 @@ int elf_init(FAR const char *filename, FAR struct elf_loadinfo_s *loadinfo) if (ret < 0) { berr("Failed to read ELF header: %d\n", ret); + close(loadinfo->filfd); return ret; } @@ -194,6 +195,7 @@ int elf_init(FAR const char *filename, FAR struct elf_loadinfo_s *loadinfo) */ berr("Bad ELF header: %d\n", ret); + close(loadinfo->filfd); return ret; } From 1b0ca4c4c532eb10c71213d31a1579b95175c265 Mon Sep 17 00:00:00 2001 From: Alin Jerpelea Date: Mon, 25 Jun 2018 11:49:04 +0900 Subject: [PATCH 3/7] binfmt: Fix stack memory leak on error --- binfmt/binfmt_execmodule.c | 1 + 1 file changed, 1 insertion(+) diff --git a/binfmt/binfmt_execmodule.c b/binfmt/binfmt_execmodule.c index b091b20a98b1d..6ccd9f722a853 100644 --- a/binfmt/binfmt_execmodule.c +++ b/binfmt/binfmt_execmodule.c @@ -186,6 +186,7 @@ int exec_module(FAR const struct binary_s *binp) { ret = -get_errno(); berr("task_init() failed: %d\n", ret); + kumm_free(stack); goto errout_with_addrenv; } From 61198129d341ae0fc1057fc20dbde8ba86198fbd Mon Sep 17 00:00:00 2001 From: Alin Jerpelea Date: Mon, 25 Jun 2018 12:00:06 +0900 Subject: [PATCH 4/7] fs: romfs: Fix private data not free on error --- fs/romfs/fs_romfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/romfs/fs_romfs.c b/fs/romfs/fs_romfs.c index 81c8630abe44f..b805d0757efb5 100644 --- a/fs/romfs/fs_romfs.c +++ b/fs/romfs/fs_romfs.c @@ -268,6 +268,7 @@ static int romfs_open(FAR struct file *filep, FAR const char *relpath, if (ret < 0) { ferr("ERROR: Failed to locate start of file data: %d\n", ret); + kmm_free(rf); goto errout_with_semaphore; } @@ -277,6 +278,7 @@ static int romfs_open(FAR struct file *filep, FAR const char *relpath, if (ret < 0) { ferr("ERROR: Failed configure buffering: %d\n", ret); + kmm_free(rf); goto errout_with_semaphore; } From 713b8f23b37d8f97cc3de3a9cf365f071571366d Mon Sep 17 00:00:00 2001 From: Alin Jerpelea Date: Wed, 26 Sep 2018 12:26:31 +0900 Subject: [PATCH 5/7] sched: group: Fix reference after free memory --- sched/group/group_create.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sched/group/group_create.c b/sched/group/group_create.c index 6f6afaacc1901..67eb186ff2bcd 100644 --- a/sched/group/group_create.c +++ b/sched/group/group_create.c @@ -343,6 +343,7 @@ int group_initialize(FAR struct task_tcb_s *tcb) if (!group->tg_members) { kmm_free(group); + tcb->cmn.group = NULL; return -ENOMEM; } From 3f1140746d37c16a349847398f33a2aa4bd047b4 Mon Sep 17 00:00:00 2001 From: Alin Jerpelea Date: Thu, 11 Jan 2018 00:01:50 +0900 Subject: [PATCH 6/7] drivers: mtd: smart: Fix trivial debug message in smartfs --- drivers/mtd/smart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/smart.c b/drivers/mtd/smart.c index 68debd681e3ee..ecd8a1a8f5bdd 100644 --- a/drivers/mtd/smart.c +++ b/drivers/mtd/smart.c @@ -4988,7 +4988,7 @@ static inline int smart_allocsector(FAR struct smart_struct_s *dev, physicalsector = smart_findfreephyssector(dev, FALSE); finfo("Alloc: log=%d, phys=%d, erase block=%d, free=%d, released=%d\n", logsector, physicalsector, physicalsector / - dev->sectorsPerBlk, dev->freesectors, dev->releasecount); + dev->sectorsPerBlk, dev->freesectors, dev->releasesectors); if (physicalsector == 0xffff) { From b91848d10d9a7c96d9c2ac3762a92bd79705bd87 Mon Sep 17 00:00:00 2001 From: Alin Jerpelea Date: Wed, 30 Jan 2019 16:08:08 +0900 Subject: [PATCH 7/7] sched: clock: Fix clock sync Fix clock sync when CONFIG_RTC_HIRES is enabled --- sched/clock/clock_initialize.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sched/clock/clock_initialize.c b/sched/clock/clock_initialize.c index 011f514f47fb6..116b0bc877c8b 100644 --- a/sched/clock/clock_initialize.c +++ b/sched/clock/clock_initialize.c @@ -175,9 +175,7 @@ static void clock_inittime(void) /* (Re-)initialize the time value to match the RTC */ #ifndef CONFIG_CLOCK_TIMEKEEPING -#ifndef CONFIG_RTC_HIRES clock_basetime(&g_basetime); -#endif #ifndef CONFIG_SCHED_TICKLESS g_system_timer = INITIAL_SYSTEM_TIMER_TICKS;