[PATCH 033/112] fs: always check path_init for errors

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

 



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@xxxxxxxxxxxxxx>
---
 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





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

  Powered by Linux