getname() can return an error when for example the input path is an
empty string. Check the getname() return value in open() before
further using it.

Signed-off-by: Sascha Hauer <[email protected]>
---
 fs/fs.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fs/fs.c b/fs/fs.c
index 2eaf7eaa37..f4baba81e7 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -2368,8 +2368,14 @@ int open(const char *pathname, int flags, ...)
        struct dentry *dentry = NULL;
        struct nameidata nd;
        const char *s;
+       struct filename *filename;
+
+       filename = getname(pathname);
+       if (IS_ERR(filename))
+               return PTR_ERR(filename);
+
+       set_nameidata(&nd, AT_FDCWD, filename);
 
-       set_nameidata(&nd, AT_FDCWD, getname(pathname));
        s = path_init(&nd, LOOKUP_FOLLOW);
 
        while (1) {
-- 
2.29.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to