[PATCH] fs: ubifs: fix ubifs_finddir() result check
Patrick Delaunay
patrick.delaunay at foss.st.com
Tue Jun 9 11:00:41 CEST 2026
ubifs_finddir() can return a negative error code (-ENOMEM or
PTR_ERR(dent)) and returns 1 when the name is found in the directory.
Fix the result check accordingly.
This fixes file existence detection (for "test -e") when U-Boot uses
UBIFS through ops ubifs_exists(). Since this function is also called
before other file operations, commands such as "load" could be executed
on a non-existing file without reporting an error.
Fixes: 0cab29ff467e ("fs: ubifs: Fix and rework error handling in ubifs_finddir")
Signed-off-by: Patrick Delaunay <patrick.delaunay at foss.st.com>
---
fs/ubifs/ubifs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 3f2e20377458..59bc75473041 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -544,7 +544,7 @@ static unsigned long ubifs_findfile(struct super_block *sb, char *filename)
*(next++) = '\0';
}
ret = ubifs_finddir(sb, name, root_inum, &inum);
- if (!ret) {
+ if (ret <= 0) {
kfree(buf);
return 0;
}
--
2.43.0
base-commit: 744cf5d4e398c5f657e5c3eeb44d00fa5175dc85
branch: dfgdfgfddd
More information about the U-Boot
mailing list