tuxera / reliance-edge

Transactional power-failsafe filesystem for microcontrollers
https://www.tuxera.com/company/open-source
GNU General Public License v2.0
109 stars 32 forks source link

An improper locking due to the unreleased lock #17

Closed ryancaicse closed 3 years ago

ryancaicse commented 3 years ago

Hi developers, in the below codes, the lock REDFS_LOCK(); could be not released before program's exit exit(1); . I think there is no harm to write REDFS_UNLOCK(); before the exit(1) for better resource management and code symmetry. Thanks!

https://github.com/datalightinc/reliance-edge/blob/b91bff1aa3c9b545b5bf289b76de5e74ea4fcfd4/os/linux/tools/fuse.c#L955-L968

jcdubois commented 3 years ago

For correctness we could certainly add a REDFS_UNLOCK() before the exit() call. However as the red_umount() call just failed we are already in a pretty bad state here. Note that if we change things here we should also change things in fuse_red_init() for coherency. Obviously, in a Unix/Posix/Linux system resource cleaning in an exit() path is not strictly necessary (but it doesn't hurt).

ryancaicse commented 3 years ago

@jcdubois OK, thank you very much

danielrlewis commented 3 years ago

Merged commit from @jcdubois, closing.