Commit bda1ef2
committed
fw/filesystem: fix crash when temp file closes while original name is open
When closing a temp file, pfs_close() calls pfs_remove() on the original
filename to delete it from flash. However, if another fd had the same
filename open as a non-temp file, pfs_remove() would find that fd with
status=IN_USE and crash with "Cannot delete X, it is currently in use".
This could happen in scenarios like:
1. A temp file is created for "app_comm" (is_tmp=TRUE)
2. Someone opens "app_comm" as regular file (is_tmp=FALSE)
3. Temp file is closed -> pfs_remove("app_comm") finds the fd from step 2
4. Crash because that fd is still IN_USE
Fix this by checking in file_found_in_cache() whether a temp file with the
same name is already in use when opening a non-temp file. If so, return
E_BUSY to prevent creating conflicting fd entries.
Signed-off-by: Joshua Jun <[email protected]>1 parent dd8e923 commit bda1ef2
1 file changed
+13
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1413 | 1413 | | |
1414 | 1414 | | |
1415 | 1415 | | |
1416 | | - | |
| 1416 | + | |
| 1417 | + | |
1417 | 1418 | | |
1418 | 1419 | | |
1419 | 1420 | | |
| |||
1716 | 1717 | | |
1717 | 1718 | | |
1718 | 1719 | | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
1719 | 1731 | | |
1720 | 1732 | | |
1721 | 1733 | | |
| |||
0 commit comments