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
94b5d262
Commit
94b5d262
authored
Feb 22, 2015
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
getname_flags(): clean up a bit
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
90a5a895
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
28 deletions
+25
-28
fs/namei.c
fs/namei.c
+25
-28
No files found.
fs/namei.c
View file @
94b5d262
...
@@ -124,10 +124,9 @@
...
@@ -124,10 +124,9 @@
struct
filename
*
struct
filename
*
getname_flags
(
const
char
__user
*
filename
,
int
flags
,
int
*
empty
)
getname_flags
(
const
char
__user
*
filename
,
int
flags
,
int
*
empty
)
{
{
struct
filename
*
result
,
*
err
;
struct
filename
*
result
;
int
len
;
long
max
;
char
*
kname
;
char
*
kname
;
int
len
;
result
=
audit_reusename
(
filename
);
result
=
audit_reusename
(
filename
);
if
(
result
)
if
(
result
)
...
@@ -136,7 +135,6 @@ getname_flags(const char __user *filename, int flags, int *empty)
...
@@ -136,7 +135,6 @@ getname_flags(const char __user *filename, int flags, int *empty)
result
=
__getname
();
result
=
__getname
();
if
(
unlikely
(
!
result
))
if
(
unlikely
(
!
result
))
return
ERR_PTR
(
-
ENOMEM
);
return
ERR_PTR
(
-
ENOMEM
);
result
->
refcnt
=
1
;
/*
/*
* First, try to embed the struct filename inside the names_cache
* First, try to embed the struct filename inside the names_cache
...
@@ -145,13 +143,11 @@ getname_flags(const char __user *filename, int flags, int *empty)
...
@@ -145,13 +143,11 @@ getname_flags(const char __user *filename, int flags, int *empty)
kname
=
(
char
*
)
result
+
sizeof
(
*
result
);
kname
=
(
char
*
)
result
+
sizeof
(
*
result
);
result
->
name
=
kname
;
result
->
name
=
kname
;
result
->
separate
=
false
;
result
->
separate
=
false
;
max
=
EMBEDDED_NAME_MAX
;
recopy:
len
=
strncpy_from_user
(
kname
,
filename
,
EMBEDDED_NAME_MAX
);
len
=
strncpy_from_user
(
kname
,
filename
,
max
);
if
(
unlikely
(
len
<
0
))
{
if
(
unlikely
(
len
<
0
))
{
err
=
ERR_PTR
(
len
);
__putname
(
result
);
goto
error
;
return
ERR_PTR
(
len
)
;
}
}
/*
/*
...
@@ -160,43 +156,44 @@ getname_flags(const char __user *filename, int flags, int *empty)
...
@@ -160,43 +156,44 @@ getname_flags(const char __user *filename, int flags, int *empty)
* names_cache allocation for the pathname, and re-do the copy from
* names_cache allocation for the pathname, and re-do the copy from
* userland.
* userland.
*/
*/
if
(
len
==
EMBEDDED_NAME_MAX
&&
max
==
EMBEDDED_NAME_MAX
)
{
if
(
unlikely
(
len
==
EMBEDDED_NAME_MAX
)
)
{
kname
=
(
char
*
)
result
;
kname
=
(
char
*
)
result
;
result
=
kzalloc
(
sizeof
(
*
result
),
GFP_KERNEL
);
result
=
kzalloc
(
sizeof
(
*
result
),
GFP_KERNEL
);
if
(
!
result
)
{
if
(
unlikely
(
!
result
))
{
err
=
ERR_PTR
(
-
ENOMEM
);
__putname
(
kname
);
result
=
(
struct
filename
*
)
kname
;
return
ERR_PTR
(
-
ENOMEM
);
goto
error
;
}
}
result
->
name
=
kname
;
result
->
name
=
kname
;
result
->
separate
=
true
;
result
->
separate
=
true
;
result
->
refcnt
=
1
;
len
=
strncpy_from_user
(
kname
,
filename
,
PATH_MAX
);
max
=
PATH_MAX
;
if
(
unlikely
(
len
<
0
))
{
goto
recopy
;
__putname
(
kname
);
kfree
(
result
);
return
ERR_PTR
(
len
);
}
if
(
unlikely
(
len
==
PATH_MAX
))
{
__putname
(
kname
);
kfree
(
result
);
return
ERR_PTR
(
-
ENAMETOOLONG
);
}
}
}
result
->
refcnt
=
1
;
/* The empty path is special. */
/* The empty path is special. */
if
(
unlikely
(
!
len
))
{
if
(
unlikely
(
!
len
))
{
if
(
empty
)
if
(
empty
)
*
empty
=
1
;
*
empty
=
1
;
err
=
ERR_PTR
(
-
ENOENT
);
if
(
!
(
flags
&
LOOKUP_EMPTY
))
{
if
(
!
(
flags
&
LOOKUP_EMPTY
))
putname
(
result
);
goto
error
;
return
ERR_PTR
(
-
ENOENT
);
}
}
}
err
=
ERR_PTR
(
-
ENAMETOOLONG
);
if
(
unlikely
(
len
>=
PATH_MAX
))
goto
error
;
result
->
uptr
=
filename
;
result
->
uptr
=
filename
;
result
->
aname
=
NULL
;
result
->
aname
=
NULL
;
audit_getname
(
result
);
audit_getname
(
result
);
return
result
;
return
result
;
error:
putname
(
result
);
return
err
;
}
}
struct
filename
*
struct
filename
*
...
...
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