Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
ac648a6a
cloud-kernel
项目概览
openanolis
/
cloud-kernel
大约 1 年 前同步成功
通知
158
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ac648a6a
编写于
4月 02, 2006
作者:
D
Dmitry Torokhov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Input: make modalias code respect allowed buffer size
Signed-off-by:
N
Dmitry Torokhov
<
dtor@mail.ru
>
上级
969b21cd
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
71 addition
and
39 deletion
+71
-39
drivers/input/input.c
drivers/input/input.c
+71
-39
未找到文件。
drivers/input/input.c
浏览文件 @
ac648a6a
...
@@ -571,15 +571,16 @@ INPUT_DEV_STRING_ATTR_SHOW(name);
...
@@ -571,15 +571,16 @@ INPUT_DEV_STRING_ATTR_SHOW(name);
INPUT_DEV_STRING_ATTR_SHOW
(
phys
);
INPUT_DEV_STRING_ATTR_SHOW
(
phys
);
INPUT_DEV_STRING_ATTR_SHOW
(
uniq
);
INPUT_DEV_STRING_ATTR_SHOW
(
uniq
);
static
int
print_modalias_bits
(
char
*
buf
,
int
size
,
char
prefix
,
unsigned
long
*
arr
,
static
int
input_print_modalias_bits
(
char
*
buf
,
int
size
,
unsigned
int
min
,
unsigned
int
max
)
char
name
,
unsigned
long
*
bm
,
unsigned
int
min_bit
,
unsigned
int
max_bit
)
{
{
int
len
,
i
;
int
len
=
0
,
i
;
len
=
snprintf
(
buf
,
size
,
"%c"
,
prefix
);
len
+=
snprintf
(
buf
,
max
(
size
,
0
),
"%c"
,
name
);
for
(
i
=
min
;
i
<
max
;
i
++
)
for
(
i
=
min
_bit
;
i
<
max_bit
;
i
++
)
if
(
arr
[
LONG
(
i
)]
&
BIT
(
i
))
if
(
bm
[
LONG
(
i
)]
&
BIT
(
i
))
len
+=
snprintf
(
buf
+
len
,
size
-
len
,
"%X,"
,
i
);
len
+=
snprintf
(
buf
+
len
,
max
(
size
-
len
,
0
)
,
"%X,"
,
i
);
return
len
;
return
len
;
}
}
...
@@ -588,33 +589,32 @@ static int input_print_modalias(char *buf, int size, struct input_dev *id,
...
@@ -588,33 +589,32 @@ static int input_print_modalias(char *buf, int size, struct input_dev *id,
{
{
int
len
;
int
len
;
len
=
snprintf
(
buf
,
size
,
"input:b%04Xv%04Xp%04Xe%04X-"
,
len
=
snprintf
(
buf
,
max
(
size
,
0
),
id
->
id
.
bustype
,
"input:b%04Xv%04Xp%04Xe%04X-"
,
id
->
id
.
vendor
,
id
->
id
.
bustype
,
id
->
id
.
vendor
,
id
->
id
.
product
,
id
->
id
.
product
,
id
->
id
.
version
);
id
->
id
.
version
);
len
+=
input_print_modalias_bits
(
buf
+
len
,
size
-
len
,
len
+=
print_modalias_bits
(
buf
+
len
,
size
-
len
,
'e'
,
id
->
evbit
,
'e'
,
id
->
evbit
,
0
,
EV_MAX
);
0
,
EV_MAX
);
len
+=
input_print_modalias_bits
(
buf
+
len
,
size
-
len
,
len
+=
print_modalias_bits
(
buf
+
len
,
size
-
len
,
'k'
,
id
->
keybit
,
'k'
,
id
->
keybit
,
KEY_MIN_INTERESTING
,
KEY_MAX
);
KEY_MIN_INTERESTING
,
KEY_MAX
);
len
+=
input_print_modalias_bits
(
buf
+
len
,
size
-
len
,
len
+=
print_modalias_bits
(
buf
+
len
,
size
-
len
,
'r'
,
id
->
relbit
,
'r'
,
id
->
relbit
,
0
,
REL_MAX
);
0
,
REL_MAX
);
len
+=
input_print_modalias_bits
(
buf
+
len
,
size
-
len
,
len
+=
print_modalias_bits
(
buf
+
len
,
size
-
len
,
'a'
,
id
->
absbit
,
'a'
,
id
->
absbit
,
0
,
ABS_MAX
);
0
,
ABS_MAX
);
len
+=
input_print_modalias_bits
(
buf
+
len
,
size
-
len
,
len
+=
print_modalias_bits
(
buf
+
len
,
size
-
len
,
'm'
,
id
->
mscbit
,
'm'
,
id
->
mscbit
,
0
,
MSC_MAX
);
0
,
MSC_MAX
);
len
+=
input_print_modalias_bits
(
buf
+
len
,
size
-
len
,
len
+=
print_modalias_bits
(
buf
+
len
,
size
-
len
,
'l'
,
id
->
ledbit
,
'l'
,
id
->
ledbit
,
0
,
LED_MAX
);
0
,
LED_MAX
);
len
+=
input_print_modalias_bits
(
buf
+
len
,
size
-
len
,
len
+=
print_modalias_bits
(
buf
+
len
,
size
-
len
,
's'
,
id
->
sndbit
,
's'
,
id
->
sndbit
,
0
,
SND_MAX
);
0
,
SND_MAX
);
len
+=
input_print_modalias_bits
(
buf
+
len
,
size
-
len
,
len
+=
print_modalias_bits
(
buf
+
len
,
size
-
len
,
'f'
,
id
->
ffbit
,
'f'
,
id
->
ffbit
,
0
,
FF_MAX
);
0
,
FF_MAX
);
len
+=
input_print_modalias_bits
(
buf
+
len
,
size
-
len
,
len
+=
print_modalias_bits
(
buf
+
len
,
size
-
len
,
'w'
,
id
->
swbit
,
'w'
,
id
->
swbit
,
0
,
SW_MAX
);
0
,
SW_MAX
);
if
(
add_cr
)
if
(
add_cr
)
len
+=
snprintf
(
buf
+
len
,
size
-
len
,
"
\n
"
);
len
+=
snprintf
(
buf
+
len
,
max
(
size
-
len
,
0
)
,
"
\n
"
);
return
len
;
return
len
;
}
}
...
@@ -739,8 +739,8 @@ static void input_dev_release(struct class_device *class_dev)
...
@@ -739,8 +739,8 @@ static void input_dev_release(struct class_device *class_dev)
* device bitfields.
* device bitfields.
*/
*/
static
int
input_add_uevent_bm_var
(
char
**
envp
,
int
num_envp
,
int
*
cur_index
,
static
int
input_add_uevent_bm_var
(
char
**
envp
,
int
num_envp
,
int
*
cur_index
,
char
*
buffer
,
int
buffer_size
,
int
*
cur_len
,
char
*
buffer
,
int
buffer_size
,
int
*
cur_len
,
const
char
*
name
,
unsigned
long
*
bitmap
,
int
max
)
const
char
*
name
,
unsigned
long
*
bitmap
,
int
max
)
{
{
if
(
*
cur_index
>=
num_envp
-
1
)
if
(
*
cur_index
>=
num_envp
-
1
)
return
-
ENOMEM
;
return
-
ENOMEM
;
...
@@ -748,7 +748,7 @@ static int input_add_uevent_bm_var(char **envp, int num_envp, int *cur_index,
...
@@ -748,7 +748,7 @@ static int input_add_uevent_bm_var(char **envp, int num_envp, int *cur_index,
envp
[
*
cur_index
]
=
buffer
+
*
cur_len
;
envp
[
*
cur_index
]
=
buffer
+
*
cur_len
;
*
cur_len
+=
snprintf
(
buffer
+
*
cur_len
,
max
(
buffer_size
-
*
cur_len
,
0
),
name
);
*
cur_len
+=
snprintf
(
buffer
+
*
cur_len
,
max
(
buffer_size
-
*
cur_len
,
0
),
name
);
if
(
*
cur_len
>
buffer_size
)
if
(
*
cur_len
>
=
buffer_size
)
return
-
ENOMEM
;
return
-
ENOMEM
;
*
cur_len
+=
input_print_bitmap
(
buffer
+
*
cur_len
,
*
cur_len
+=
input_print_bitmap
(
buffer
+
*
cur_len
,
...
@@ -761,9 +761,33 @@ static int input_add_uevent_bm_var(char **envp, int num_envp, int *cur_index,
...
@@ -761,9 +761,33 @@ static int input_add_uevent_bm_var(char **envp, int num_envp, int *cur_index,
return
0
;
return
0
;
}
}
static
int
input_add_uevent_modalias_var
(
char
**
envp
,
int
num_envp
,
int
*
cur_index
,
char
*
buffer
,
int
buffer_size
,
int
*
cur_len
,
struct
input_dev
*
dev
)
{
if
(
*
cur_index
>=
num_envp
-
1
)
return
-
ENOMEM
;
envp
[
*
cur_index
]
=
buffer
+
*
cur_len
;
*
cur_len
+=
snprintf
(
buffer
+
*
cur_len
,
max
(
buffer_size
-
*
cur_len
,
0
),
"MODALIAS="
);
if
(
*
cur_len
>=
buffer_size
)
return
-
ENOMEM
;
*
cur_len
+=
input_print_modalias
(
buffer
+
*
cur_len
,
max
(
buffer_size
-
*
cur_len
,
0
),
dev
,
0
)
+
1
;
if
(
*
cur_len
>
buffer_size
)
return
-
ENOMEM
;
(
*
cur_index
)
++
;
return
0
;
}
#define INPUT_ADD_HOTPLUG_VAR(fmt, val...) \
#define INPUT_ADD_HOTPLUG_VAR(fmt, val...) \
do { \
do { \
int err = add_uevent_var(envp, num_envp, &i, \
int err = add_uevent_var(envp, num_envp, &i,
\
buffer, buffer_size, &len, \
buffer, buffer_size, &len, \
fmt, val); \
fmt, val); \
if (err) \
if (err) \
...
@@ -779,6 +803,16 @@ static int input_add_uevent_bm_var(char **envp, int num_envp, int *cur_index,
...
@@ -779,6 +803,16 @@ static int input_add_uevent_bm_var(char **envp, int num_envp, int *cur_index,
return err; \
return err; \
} while (0)
} while (0)
#define INPUT_ADD_HOTPLUG_MODALIAS_VAR(dev) \
do { \
int err = input_add_uevent_modalias_var(envp, \
num_envp, &i, \
buffer, buffer_size, &len, \
dev); \
if (err) \
return err; \
} while (0)
static
int
input_dev_uevent
(
struct
class_device
*
cdev
,
char
**
envp
,
static
int
input_dev_uevent
(
struct
class_device
*
cdev
,
char
**
envp
,
int
num_envp
,
char
*
buffer
,
int
buffer_size
)
int
num_envp
,
char
*
buffer
,
int
buffer_size
)
{
{
...
@@ -814,9 +848,7 @@ static int input_dev_uevent(struct class_device *cdev, char **envp,
...
@@ -814,9 +848,7 @@ static int input_dev_uevent(struct class_device *cdev, char **envp,
if
(
test_bit
(
EV_SW
,
dev
->
evbit
))
if
(
test_bit
(
EV_SW
,
dev
->
evbit
))
INPUT_ADD_HOTPLUG_BM_VAR
(
"SW="
,
dev
->
swbit
,
SW_MAX
);
INPUT_ADD_HOTPLUG_BM_VAR
(
"SW="
,
dev
->
swbit
,
SW_MAX
);
envp
[
i
++
]
=
buffer
+
len
;
INPUT_ADD_HOTPLUG_MODALIAS_VAR
(
dev
);
len
+=
snprintf
(
buffer
+
len
,
buffer_size
-
len
,
"MODALIAS="
);
len
+=
input_print_modalias
(
buffer
+
len
,
buffer_size
-
len
,
dev
,
0
)
+
1
;
envp
[
i
]
=
NULL
;
envp
[
i
]
=
NULL
;
return
0
;
return
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录