[PATCH 3/3] fs: check getname() return value in open()
Sascha Hauer
s.hauer at pengutronix.de
Fri May 7 03:56:11 PDT 2021
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 <s.hauer at pengutronix.de>
---
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
More information about the barebox
mailing list