Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
251d5951
R
raspberrypi-kernel
项目概览
openeuler
/
raspberrypi-kernel
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
raspberrypi-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
251d5951
编写于
4月 20, 2017
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
spidev: quit messing with access_ok()
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
2ea659a9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
11 addition
and
31 deletion
+11
-31
drivers/spi/spidev.c
drivers/spi/spidev.c
+11
-31
未找到文件。
drivers/spi/spidev.c
浏览文件 @
251d5951
...
...
@@ -254,10 +254,6 @@ static int spidev_message(struct spidev_data *spidev,
goto
done
;
}
k_tmp
->
rx_buf
=
rx_buf
;
if
(
!
access_ok
(
VERIFY_WRITE
,
(
u8
__user
*
)
(
uintptr_t
)
u_tmp
->
rx_buf
,
u_tmp
->
len
))
goto
done
;
rx_buf
+=
k_tmp
->
len
;
}
if
(
u_tmp
->
tx_buf
)
{
...
...
@@ -305,7 +301,7 @@ static int spidev_message(struct spidev_data *spidev,
rx_buf
=
spidev
->
rx_buffer
;
for
(
n
=
n_xfers
,
u_tmp
=
u_xfers
;
n
;
n
--
,
u_tmp
++
)
{
if
(
u_tmp
->
rx_buf
)
{
if
(
__
copy_to_user
((
u8
__user
*
)
if
(
copy_to_user
((
u8
__user
*
)
(
uintptr_t
)
u_tmp
->
rx_buf
,
rx_buf
,
u_tmp
->
len
))
{
status
=
-
EFAULT
;
...
...
@@ -355,7 +351,6 @@ spidev_get_ioc_message(unsigned int cmd, struct spi_ioc_transfer __user *u_ioc,
static
long
spidev_ioctl
(
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
int
err
=
0
;
int
retval
=
0
;
struct
spidev_data
*
spidev
;
struct
spi_device
*
spi
;
...
...
@@ -367,19 +362,6 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
if
(
_IOC_TYPE
(
cmd
)
!=
SPI_IOC_MAGIC
)
return
-
ENOTTY
;
/* Check access direction once here; don't repeat below.
* IOC_DIR is from the user perspective, while access_ok is
* from the kernel perspective; so they look reversed.
*/
if
(
_IOC_DIR
(
cmd
)
&
_IOC_READ
)
err
=
!
access_ok
(
VERIFY_WRITE
,
(
void
__user
*
)
arg
,
_IOC_SIZE
(
cmd
));
if
(
err
==
0
&&
_IOC_DIR
(
cmd
)
&
_IOC_WRITE
)
err
=
!
access_ok
(
VERIFY_READ
,
(
void
__user
*
)
arg
,
_IOC_SIZE
(
cmd
));
if
(
err
)
return
-
EFAULT
;
/* guard against device removal before, or while,
* we issue this ioctl.
*/
...
...
@@ -402,31 +384,31 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
switch
(
cmd
)
{
/* read requests */
case
SPI_IOC_RD_MODE
:
retval
=
__
put_user
(
spi
->
mode
&
SPI_MODE_MASK
,
retval
=
put_user
(
spi
->
mode
&
SPI_MODE_MASK
,
(
__u8
__user
*
)
arg
);
break
;
case
SPI_IOC_RD_MODE32
:
retval
=
__
put_user
(
spi
->
mode
&
SPI_MODE_MASK
,
retval
=
put_user
(
spi
->
mode
&
SPI_MODE_MASK
,
(
__u32
__user
*
)
arg
);
break
;
case
SPI_IOC_RD_LSB_FIRST
:
retval
=
__
put_user
((
spi
->
mode
&
SPI_LSB_FIRST
)
?
1
:
0
,
retval
=
put_user
((
spi
->
mode
&
SPI_LSB_FIRST
)
?
1
:
0
,
(
__u8
__user
*
)
arg
);
break
;
case
SPI_IOC_RD_BITS_PER_WORD
:
retval
=
__
put_user
(
spi
->
bits_per_word
,
(
__u8
__user
*
)
arg
);
retval
=
put_user
(
spi
->
bits_per_word
,
(
__u8
__user
*
)
arg
);
break
;
case
SPI_IOC_RD_MAX_SPEED_HZ
:
retval
=
__
put_user
(
spidev
->
speed_hz
,
(
__u32
__user
*
)
arg
);
retval
=
put_user
(
spidev
->
speed_hz
,
(
__u32
__user
*
)
arg
);
break
;
/* write requests */
case
SPI_IOC_WR_MODE
:
case
SPI_IOC_WR_MODE32
:
if
(
cmd
==
SPI_IOC_WR_MODE
)
retval
=
__
get_user
(
tmp
,
(
u8
__user
*
)
arg
);
retval
=
get_user
(
tmp
,
(
u8
__user
*
)
arg
);
else
retval
=
__
get_user
(
tmp
,
(
u32
__user
*
)
arg
);
retval
=
get_user
(
tmp
,
(
u32
__user
*
)
arg
);
if
(
retval
==
0
)
{
u32
save
=
spi
->
mode
;
...
...
@@ -445,7 +427,7 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
}
break
;
case
SPI_IOC_WR_LSB_FIRST
:
retval
=
__
get_user
(
tmp
,
(
__u8
__user
*
)
arg
);
retval
=
get_user
(
tmp
,
(
__u8
__user
*
)
arg
);
if
(
retval
==
0
)
{
u32
save
=
spi
->
mode
;
...
...
@@ -462,7 +444,7 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
}
break
;
case
SPI_IOC_WR_BITS_PER_WORD
:
retval
=
__
get_user
(
tmp
,
(
__u8
__user
*
)
arg
);
retval
=
get_user
(
tmp
,
(
__u8
__user
*
)
arg
);
if
(
retval
==
0
)
{
u8
save
=
spi
->
bits_per_word
;
...
...
@@ -475,7 +457,7 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
}
break
;
case
SPI_IOC_WR_MAX_SPEED_HZ
:
retval
=
__
get_user
(
tmp
,
(
__u32
__user
*
)
arg
);
retval
=
get_user
(
tmp
,
(
__u32
__user
*
)
arg
);
if
(
retval
==
0
)
{
u32
save
=
spi
->
max_speed_hz
;
...
...
@@ -525,8 +507,6 @@ spidev_compat_ioc_message(struct file *filp, unsigned int cmd,
struct
spi_ioc_transfer
*
ioc
;
u_ioc
=
(
struct
spi_ioc_transfer
__user
*
)
compat_ptr
(
arg
);
if
(
!
access_ok
(
VERIFY_READ
,
u_ioc
,
_IOC_SIZE
(
cmd
)))
return
-
EFAULT
;
/* guard against device removal before, or while,
* we issue this ioctl.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录