Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
e4b27553
Commit
e4b27553
authored
May 16, 2021
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
getcwd(2): clean up error handling
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
cf4febc1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
17 deletions
+12
-17
fs/d_path.c
fs/d_path.c
+12
-17
No files found.
fs/d_path.c
View file @
e4b27553
...
...
@@ -390,9 +390,11 @@ SYSCALL_DEFINE2(getcwd, char __user *, buf, unsigned long, size)
rcu_read_lock
();
get_fs_root_and_pwd_rcu
(
current
->
fs
,
&
root
,
&
pwd
);
error
=
-
ENOENT
;
if
(
!
d_unlinked
(
pwd
.
dentry
))
{
unsigned
long
len
;
if
(
unlikely
(
d_unlinked
(
pwd
.
dentry
)))
{
rcu_read_unlock
();
error
=
-
ENOENT
;
}
else
{
unsigned
len
;
DECLARE_BUFFER
(
b
,
page
,
PATH_MAX
);
prepend
(
&
b
,
""
,
1
);
...
...
@@ -400,23 +402,16 @@ SYSCALL_DEFINE2(getcwd, char __user *, buf, unsigned long, size)
prepend
(
&
b
,
"(unreachable)"
,
13
);
rcu_read_unlock
();
if
(
b
.
len
<
0
)
{
error
=
-
ENAMETOOLONG
;
goto
out
;
}
error
=
-
ERANGE
;
len
=
PATH_MAX
-
b
.
len
;
if
(
len
<=
size
)
{
if
(
unlikely
(
len
>
PATH_MAX
))
error
=
-
ENAMETOOLONG
;
else
if
(
unlikely
(
len
>
size
))
error
=
-
ERANGE
;
else
if
(
copy_to_user
(
buf
,
b
.
buf
,
len
))
error
=
-
EFAULT
;
else
error
=
len
;
if
(
copy_to_user
(
buf
,
b
.
buf
,
len
))
error
=
-
EFAULT
;
}
}
else
{
rcu_read_unlock
();
}
out:
__putname
(
page
);
return
error
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment