[PATCH 3/3] fs: check getname() return value in open()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux