[PATCH v2 033/113] fs: always check path_init for errors
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Mar 4 10:59:18 PST 2024
We have three calls to path_init, but Only one of them checks the returned
pointer value for errors. This didn't hurt so far, because the function
always succeeded, but a follow-up commit will cause it to fail in some
circumstances, so prepare for that by duly checking the return value.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
fs/fs.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/fs.c b/fs/fs.c
index be0b38d8bc30..c034f2cb9a0d 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -2324,6 +2324,8 @@ static int filename_lookup(struct filename *name, unsigned flags,
set_nameidata(&nd, name);
s = path_init(&nd, flags);
+ if (IS_ERR(s))
+ return PTR_ERR(s);
while (!(err = link_path_walk(s, &nd)) && ((err = lookup_last(&nd)) > 0)) {
s = trailing_symlink(&nd);
@@ -2529,6 +2531,8 @@ int open(const char *pathname, int flags, ...)
set_nameidata(&nd, filename);
s = path_init(&nd, LOOKUP_FOLLOW);
+ if (IS_ERR(s))
+ return PTR_ERR(s);
while (1) {
error = link_path_walk(s, &nd);
--
2.39.2
More information about the barebox
mailing list