fs/inode: propagate inode search errors - #20038
Conversation
|
91a6a0e to
d371bb1
Compare
d371bb1 to
69d6ac4
Compare
|
Hi @xiaoxiang781216 and @jerpelea , the CI formatting issues have been addressed and the latest changes have been pushed. Could you please review this PR when you have time? Thank you! |
@imeghar2408-max still error, you can run ./tools/checkpatch.sh -g HEAD~...HEAD before update. |
inode_reserve() previously continued processing all negative return values from inode_search(). Only -ENOENT indicates that the target inode is absent and creation may continue. Propagate other search errors through the existing cleanup path to avoid continuing inode creation with invalid insertion metadata. Assisted-by: GitHub Copilot Signed-off-by: Megha Rajput <i.meghar.2408@gmail.com>
69d6ac4 to
cec8d8c
Compare
Hi Xiaoxiang, thanks for the suggestion. I updated the commit message and ran ./tools/checkpatch.sh -c -u -m -g ..HEAD locally; all checks pass now. I've pushed the updated commit. Thank you! |

Summary
Fix
inode_reserve()to propagate inode search errors instead of continuinginode creation for every negative return from
inode_search().inode_search()returns-ENOENTwhen the path is valid but the target inodedoes not exist yet. Other negative returns indicate an actual lookup or path
error, such as
-ENAMETOOLONG.Previously,
inode_reserve()continued processing any negative return. For anoverlong pathname, this could leave the insertion metadata invalid and reach
inode_insert()with aNULLparent, triggering an assertion.This change allows inode creation to continue only when
inode_search()returns-ENOENT. All other errors are propagated through the existing cleanup path.Testing
Tested on the NuttX simulator with ProcFS, TMPFS, and ASan enabled.
No ASan error was reported during the tests.
1. Regression test: overlong pathname
Before the fix
Running an overlong mount path:
triggered:
The simulator therefore hit the
NULLparent assertion ininode_reserve().After the fix
The same command returned:
where
36isENAMETOOLONG.No assertion or crash occurred.
2. Valid pathname / normal inode creation
A valid mount was verified:
The mount was then confirmed with:
This confirms that valid inode creation and mounting still work after the change.
3. Existing inode handling
Created
/a/band then attempted to create it again:where
17isEEXIST.This confirms that an existing inode is still handled as an existing target
rather than being treated as a missing inode.
4. Build
The NuttX simulator build completed successfully with
CONFIG_SIM_ASAN=y:5. Static checks
The following checks passed:
6. PATH_MAX-specific case
A separate runtime test targeting the
PATH_MAXlimit was attempted, but thelong NSH input could not be delivered reliably in the simulator environment.
Therefore, no
PATH_MAXruntime result is claimed here.