diff options
| author | Allan ELKAIM <[email protected]> | 2026-07-13 16:22:47 +0200 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2026-07-24 18:39:29 -0600 |
| commit | 171b604888537dd7112ffddaa13abb16932eabd0 (patch) | |
| tree | bc4e3b46241e20ed054ee56ff232c1f5ca5e8d24 /lib | |
| parent | 57e0bb7bf00dadd7537f93609afb955108ce22c7 (diff) | |
fs/squashfs: fix dirs->entry leaks on sqfs_search_dir() error paths
Several error paths in sqfs_search_dir() return through 'goto out'
while a directory entry obtained from sqfs_readdir_nest() is still
held, leaking dirs->entry: the inode lookup failure, the symlink
nesting limit check, every allocation/tokenization failure during
symlink resolution, and the case where readdir aborts after an
entry was already read.
Instead of freeing dirs->entry at each error site, centralize the
cleanup at the 'out' label: on error, no valid entry may be handed
back to the caller, so it can be freed unconditionally there. On
success, dirs->entry is already NULL: it is freed at the end of
each token iteration and before recursing into a symlink target,
and the root directory path never allocates it.
Explicit frees remain only where a success path needs them:
between reads in the readdir loop, at the end of each token
iteration, and before the recursive call. The now-redundant frees
on individual error paths are removed.
Suggested-by: Richard Genoud <[email protected]>
Signed-off-by: Allan ELKAIM <[email protected]>
Diffstat (limited to 'lib')
0 files changed, 0 insertions, 0 deletions
