Skip to content

Commit

Permalink
various fixes (#49)
Browse files Browse the repository at this point in the history
* libs: libc: math: Fix tanh() math functions
* drivers: mtd: smart: Fix trivial debug message in smartfs
* binfmt: libelf: Fix fd not closed on error
* binfmt: Fix stack memory leak on error
* fs: romfs: Fix private data not free on error
* sched: group: Fix reference after free memory
* sched: clock: Fix clock sync

Fix clock sync when CONFIG_RTC_HIRES is enabled
  • Loading branch information
jerpelea authored and patacongo committed Jan 7, 2020
1 parent 077ef70 commit a8d63c0
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions binfmt/binfmt_execmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions binfmt/libelf/libelf_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/mtd/smart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 2 additions & 0 deletions fs/romfs/fs_romfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion libs/libc/math/lib_tanh.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion libs/libc/math/lib_tanhf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
2 changes: 1 addition & 1 deletion libs/libc/math/lib_tanhl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions sched/clock/clock_initialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions sched/group/group_create.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit a8d63c0

Please sign in to comment.