Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
46230aa6
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看板
提交
46230aa6
编写于
3月 16, 2007
作者:
R
Ralf Baechle
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[MIPS] RTLX: Handle copy_*_user return values.
Signed-off-by:
N
Ralf Baechle
<
ralf@linux-mips.org
>
上级
bc4809e9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
37 addition
and
31 deletion
+37
-31
arch/mips/kernel/kspd.c
arch/mips/kernel/kspd.c
+14
-4
arch/mips/kernel/rtlx.c
arch/mips/kernel/rtlx.c
+21
-25
include/asm-mips/rtlx.h
include/asm-mips/rtlx.h
+2
-2
未找到文件。
arch/mips/kernel/kspd.c
浏览文件 @
46230aa6
...
...
@@ -191,6 +191,8 @@ void sp_work_handle_request(void)
struct
mtsp_syscall_generic
generic
;
struct
mtsp_syscall_ret
ret
;
struct
kspd_notifications
*
n
;
unsigned
long
written
;
mm_segment_t
old_fs
;
struct
timeval
tv
;
struct
timezone
tz
;
int
cmd
;
...
...
@@ -201,7 +203,11 @@ void sp_work_handle_request(void)
ret
.
retval
=
-
1
;
if
(
!
rtlx_read
(
RTLX_CHANNEL_SYSIO
,
&
sc
,
sizeof
(
struct
mtsp_syscall
),
0
))
{
old_fs
=
get_fs
();
set_fs
(
KERNEL_DS
);
if
(
!
rtlx_read
(
RTLX_CHANNEL_SYSIO
,
&
sc
,
sizeof
(
struct
mtsp_syscall
)))
{
set_fs
(
old_fs
);
printk
(
KERN_ERR
"Expected request but nothing to read
\n
"
);
return
;
}
...
...
@@ -209,7 +215,8 @@ void sp_work_handle_request(void)
size
=
sc
.
size
;
if
(
size
)
{
if
(
!
rtlx_read
(
RTLX_CHANNEL_SYSIO
,
&
generic
,
size
,
0
))
{
if
(
!
rtlx_read
(
RTLX_CHANNEL_SYSIO
,
&
generic
,
size
))
{
set_fs
(
old_fs
);
printk
(
KERN_ERR
"Expected request but nothing to read
\n
"
);
return
;
}
...
...
@@ -282,8 +289,11 @@ void sp_work_handle_request(void)
if
(
vpe_getuid
(
SP_VPE
))
sp_setfsuidgid
(
0
,
0
);
if
((
rtlx_write
(
RTLX_CHANNEL_SYSIO
,
&
ret
,
sizeof
(
struct
mtsp_syscall_ret
),
0
))
<
sizeof
(
struct
mtsp_syscall_ret
))
old_fs
=
get_fs
();
set_fs
(
KERNEL_DS
);
written
=
rtlx_write
(
RTLX_CHANNEL_SYSIO
,
&
ret
,
sizeof
(
ret
));
set_fs
(
old_fs
);
if
(
written
<
sizeof
(
ret
))
printk
(
"KSPD: sp_work_handle_request failed to send to SP
\n
"
);
}
...
...
arch/mips/kernel/rtlx.c
浏览文件 @
46230aa6
...
...
@@ -289,26 +289,11 @@ unsigned int rtlx_write_poll(int index)
return
write_spacefree
(
chan
->
rt_read
,
chan
->
rt_write
,
chan
->
buffer_size
);
}
static
inline
void
copy_to
(
void
*
dst
,
void
*
src
,
size_t
count
,
int
user
)
{
if
(
user
)
copy_to_user
(
dst
,
src
,
count
);
else
memcpy
(
dst
,
src
,
count
);
}
static
inline
void
copy_from
(
void
*
dst
,
void
*
src
,
size_t
count
,
int
user
)
{
if
(
user
)
copy_from_user
(
dst
,
src
,
count
);
else
memcpy
(
dst
,
src
,
count
);
}
ssize_t
rtlx_read
(
int
index
,
void
*
buff
,
size_t
count
,
int
user
)
ssize_t
rtlx_read
(
int
index
,
void
__user
*
buff
,
size_t
count
,
int
user
)
{
size_t
lx_write
,
fl
=
0L
;
struct
rtlx_channel
*
lx
;
unsigned
long
failed
;
if
(
rtlx
==
NULL
)
return
-
ENOSYS
;
...
...
@@ -327,11 +312,16 @@ ssize_t rtlx_read(int index, void *buff, size_t count, int user)
/* then how much from the read pointer onwards */
fl
=
min
(
count
,
(
size_t
)
lx
->
buffer_size
-
lx
->
lx_read
);
copy_to
(
buff
,
lx
->
lx_buffer
+
lx
->
lx_read
,
fl
,
user
);
failed
=
copy_to_user
(
buff
,
lx
->
lx_buffer
+
lx
->
lx_read
,
fl
);
if
(
failed
)
goto
out
;
/* and if there is anything left at the beginning of the buffer */
if
(
count
-
fl
)
copy_to
(
buff
+
fl
,
lx
->
lx_buffer
,
count
-
fl
,
user
);
failed
=
copy_to_user
(
buff
+
fl
,
lx
->
lx_buffer
,
count
-
fl
);
out:
count
-=
failed
;
smp_wmb
();
lx
->
lx_read
=
(
lx
->
lx_read
+
count
)
%
lx
->
buffer_size
;
...
...
@@ -341,7 +331,7 @@ ssize_t rtlx_read(int index, void *buff, size_t count, int user)
return
count
;
}
ssize_t
rtlx_write
(
int
index
,
void
*
buffer
,
size_t
count
,
int
user
)
ssize_t
rtlx_write
(
int
index
,
const
void
__user
*
buffer
,
size_t
count
,
int
user
)
{
struct
rtlx_channel
*
rt
;
size_t
rt_read
;
...
...
@@ -363,11 +353,17 @@ ssize_t rtlx_write(int index, void *buffer, size_t count, int user)
/* first bit from write pointer to the end of the buffer, or count */
fl
=
min
(
count
,
(
size_t
)
rt
->
buffer_size
-
rt
->
rt_write
);
copy_from
(
rt
->
rt_buffer
+
rt
->
rt_write
,
buffer
,
fl
,
user
);
failed
=
copy_from_user
(
rt
->
rt_buffer
+
rt
->
rt_write
,
buffer
,
fl
);
if
(
failed
)
goto
out
;
/* if there's any left copy to the beginning of the buffer */
if
(
count
-
fl
)
copy_from
(
rt
->
rt_buffer
,
buffer
+
fl
,
count
-
fl
,
user
);
if
(
count
-
fl
)
{
failed
=
copy_from_user
(
rt
->
rt_buffer
,
buffer
+
fl
,
count
-
fl
);
}
out:
count
-=
cailed
;
smp_wmb
();
rt
->
rt_write
=
(
rt
->
rt_write
+
count
)
%
rt
->
buffer_size
;
...
...
@@ -426,7 +422,7 @@ static ssize_t file_read(struct file *file, char __user * buffer, size_t count,
return
0
;
// -EAGAIN makes cat whinge
}
return
rtlx_read
(
minor
,
buffer
,
count
,
1
);
return
rtlx_read
(
minor
,
buffer
,
count
);
}
static
ssize_t
file_write
(
struct
file
*
file
,
const
char
__user
*
buffer
,
...
...
@@ -452,7 +448,7 @@ static ssize_t file_write(struct file *file, const char __user * buffer,
return
ret
;
}
return
rtlx_write
(
minor
,
(
void
*
)
buffer
,
count
,
1
);
return
rtlx_write
(
minor
,
buffer
,
count
);
}
static
const
struct
file_operations
rtlx_fops
=
{
...
...
include/asm-mips/rtlx.h
浏览文件 @
46230aa6
...
...
@@ -23,8 +23,8 @@
extern
int
rtlx_open
(
int
index
,
int
can_sleep
);
extern
int
rtlx_release
(
int
index
);
extern
ssize_t
rtlx_read
(
int
index
,
void
*
buff
,
size_t
count
,
int
user
);
extern
ssize_t
rtlx_write
(
int
index
,
void
*
buffer
,
size_t
count
,
int
user
);
extern
ssize_t
rtlx_read
(
int
index
,
void
__user
*
buff
,
size_t
count
);
extern
ssize_t
rtlx_write
(
int
index
,
const
void
__user
*
buffer
,
size_t
count
);
extern
unsigned
int
rtlx_read_poll
(
int
index
,
int
can_sleep
);
extern
unsigned
int
rtlx_write_poll
(
int
index
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录