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
30e7e3ec
Commit
30e7e3ec
authored
May 13, 2017
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ethtool: don't open-code memdup_user()
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
a2c841d9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
14 deletions
+6
-14
net/core/ethtool.c
net/core/ethtool.c
+6
-14
No files found.
net/core/ethtool.c
View file @
30e7e3ec
...
@@ -2322,16 +2322,12 @@ static int ethtool_set_tunable(struct net_device *dev, void __user *useraddr)
...
@@ -2322,16 +2322,12 @@ static int ethtool_set_tunable(struct net_device *dev, void __user *useraddr)
ret
=
ethtool_tunable_valid
(
&
tuna
);
ret
=
ethtool_tunable_valid
(
&
tuna
);
if
(
ret
)
if
(
ret
)
return
ret
;
return
ret
;
data
=
kmalloc
(
tuna
.
len
,
GFP_USER
);
if
(
!
data
)
return
-
ENOMEM
;
useraddr
+=
sizeof
(
tuna
);
useraddr
+=
sizeof
(
tuna
);
ret
=
-
EFAULT
;
data
=
memdup_user
(
useraddr
,
tuna
.
len
)
;
if
(
copy_from_user
(
data
,
useraddr
,
tuna
.
len
))
if
(
IS_ERR
(
data
))
goto
out
;
return
PTR_ERR
(
data
)
;
ret
=
ops
->
set_tunable
(
dev
,
&
tuna
,
data
);
ret
=
ops
->
set_tunable
(
dev
,
&
tuna
,
data
);
out:
kfree
(
data
);
kfree
(
data
);
return
ret
;
return
ret
;
}
}
...
@@ -2507,18 +2503,14 @@ static int set_phy_tunable(struct net_device *dev, void __user *useraddr)
...
@@ -2507,18 +2503,14 @@ static int set_phy_tunable(struct net_device *dev, void __user *useraddr)
ret
=
ethtool_phy_tunable_valid
(
&
tuna
);
ret
=
ethtool_phy_tunable_valid
(
&
tuna
);
if
(
ret
)
if
(
ret
)
return
ret
;
return
ret
;
data
=
kmalloc
(
tuna
.
len
,
GFP_USER
);
if
(
!
data
)
return
-
ENOMEM
;
useraddr
+=
sizeof
(
tuna
);
useraddr
+=
sizeof
(
tuna
);
ret
=
-
EFAULT
;
data
=
memdup_user
(
useraddr
,
tuna
.
len
)
;
if
(
copy_from_user
(
data
,
useraddr
,
tuna
.
len
))
if
(
IS_ERR
(
data
))
goto
out
;
return
PTR_ERR
(
data
)
;
mutex_lock
(
&
phydev
->
lock
);
mutex_lock
(
&
phydev
->
lock
);
ret
=
phydev
->
drv
->
set_tunable
(
phydev
,
&
tuna
,
data
);
ret
=
phydev
->
drv
->
set_tunable
(
phydev
,
&
tuna
,
data
);
mutex_unlock
(
&
phydev
->
lock
);
mutex_unlock
(
&
phydev
->
lock
);
out:
kfree
(
data
);
kfree
(
data
);
return
ret
;
return
ret
;
}
}
...
...
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