Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
94109c9f
K
Kernel
项目概览
openeuler
/
Kernel
大约 2 年 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
94109c9f
编写于
2月 22, 2023
作者:
B
Benjamin Tissoires
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'for-6.3/asus' into for-linus
UAF protection in work struct (Pietro Borrello)
上级
06db2af3
4ab3a086
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
32 addition
and
5 deletion
+32
-5
drivers/hid/hid-asus.c
drivers/hid/hid-asus.c
+32
-5
未找到文件。
drivers/hid/hid-asus.c
浏览文件 @
94109c9f
...
@@ -98,6 +98,7 @@ struct asus_kbd_leds {
...
@@ -98,6 +98,7 @@ struct asus_kbd_leds {
struct
hid_device
*
hdev
;
struct
hid_device
*
hdev
;
struct
work_struct
work
;
struct
work_struct
work
;
unsigned
int
brightness
;
unsigned
int
brightness
;
spinlock_t
lock
;
bool
removed
;
bool
removed
;
};
};
...
@@ -490,21 +491,42 @@ static int rog_nkey_led_init(struct hid_device *hdev)
...
@@ -490,21 +491,42 @@ static int rog_nkey_led_init(struct hid_device *hdev)
return
ret
;
return
ret
;
}
}
static
void
asus_schedule_work
(
struct
asus_kbd_leds
*
led
)
{
unsigned
long
flags
;
spin_lock_irqsave
(
&
led
->
lock
,
flags
);
if
(
!
led
->
removed
)
schedule_work
(
&
led
->
work
);
spin_unlock_irqrestore
(
&
led
->
lock
,
flags
);
}
static
void
asus_kbd_backlight_set
(
struct
led_classdev
*
led_cdev
,
static
void
asus_kbd_backlight_set
(
struct
led_classdev
*
led_cdev
,
enum
led_brightness
brightness
)
enum
led_brightness
brightness
)
{
{
struct
asus_kbd_leds
*
led
=
container_of
(
led_cdev
,
struct
asus_kbd_leds
,
struct
asus_kbd_leds
*
led
=
container_of
(
led_cdev
,
struct
asus_kbd_leds
,
cdev
);
cdev
);
unsigned
long
flags
;
spin_lock_irqsave
(
&
led
->
lock
,
flags
);
led
->
brightness
=
brightness
;
led
->
brightness
=
brightness
;
schedule_work
(
&
led
->
work
);
spin_unlock_irqrestore
(
&
led
->
lock
,
flags
);
asus_schedule_work
(
led
);
}
}
static
enum
led_brightness
asus_kbd_backlight_get
(
struct
led_classdev
*
led_cdev
)
static
enum
led_brightness
asus_kbd_backlight_get
(
struct
led_classdev
*
led_cdev
)
{
{
struct
asus_kbd_leds
*
led
=
container_of
(
led_cdev
,
struct
asus_kbd_leds
,
struct
asus_kbd_leds
*
led
=
container_of
(
led_cdev
,
struct
asus_kbd_leds
,
cdev
);
cdev
);
enum
led_brightness
brightness
;
unsigned
long
flags
;
spin_lock_irqsave
(
&
led
->
lock
,
flags
);
brightness
=
led
->
brightness
;
spin_unlock_irqrestore
(
&
led
->
lock
,
flags
);
return
led
->
brightness
;
return
brightness
;
}
}
static
void
asus_kbd_backlight_work
(
struct
work_struct
*
work
)
static
void
asus_kbd_backlight_work
(
struct
work_struct
*
work
)
...
@@ -512,11 +534,11 @@ static void asus_kbd_backlight_work(struct work_struct *work)
...
@@ -512,11 +534,11 @@ static void asus_kbd_backlight_work(struct work_struct *work)
struct
asus_kbd_leds
*
led
=
container_of
(
work
,
struct
asus_kbd_leds
,
work
);
struct
asus_kbd_leds
*
led
=
container_of
(
work
,
struct
asus_kbd_leds
,
work
);
u8
buf
[]
=
{
FEATURE_KBD_REPORT_ID
,
0xba
,
0xc5
,
0xc4
,
0x00
};
u8
buf
[]
=
{
FEATURE_KBD_REPORT_ID
,
0xba
,
0xc5
,
0xc4
,
0x00
};
int
ret
;
int
ret
;
unsigned
long
flags
;
if
(
led
->
removed
)
spin_lock_irqsave
(
&
led
->
lock
,
flags
);
return
;
buf
[
4
]
=
led
->
brightness
;
buf
[
4
]
=
led
->
brightness
;
spin_unlock_irqrestore
(
&
led
->
lock
,
flags
);
ret
=
asus_kbd_set_report
(
led
->
hdev
,
buf
,
sizeof
(
buf
));
ret
=
asus_kbd_set_report
(
led
->
hdev
,
buf
,
sizeof
(
buf
));
if
(
ret
<
0
)
if
(
ret
<
0
)
...
@@ -584,6 +606,7 @@ static int asus_kbd_register_leds(struct hid_device *hdev)
...
@@ -584,6 +606,7 @@ static int asus_kbd_register_leds(struct hid_device *hdev)
drvdata
->
kbd_backlight
->
cdev
.
brightness_set
=
asus_kbd_backlight_set
;
drvdata
->
kbd_backlight
->
cdev
.
brightness_set
=
asus_kbd_backlight_set
;
drvdata
->
kbd_backlight
->
cdev
.
brightness_get
=
asus_kbd_backlight_get
;
drvdata
->
kbd_backlight
->
cdev
.
brightness_get
=
asus_kbd_backlight_get
;
INIT_WORK
(
&
drvdata
->
kbd_backlight
->
work
,
asus_kbd_backlight_work
);
INIT_WORK
(
&
drvdata
->
kbd_backlight
->
work
,
asus_kbd_backlight_work
);
spin_lock_init
(
&
drvdata
->
kbd_backlight
->
lock
);
ret
=
devm_led_classdev_register
(
&
hdev
->
dev
,
&
drvdata
->
kbd_backlight
->
cdev
);
ret
=
devm_led_classdev_register
(
&
hdev
->
dev
,
&
drvdata
->
kbd_backlight
->
cdev
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
...
@@ -1119,9 +1142,13 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
...
@@ -1119,9 +1142,13 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
static
void
asus_remove
(
struct
hid_device
*
hdev
)
static
void
asus_remove
(
struct
hid_device
*
hdev
)
{
{
struct
asus_drvdata
*
drvdata
=
hid_get_drvdata
(
hdev
);
struct
asus_drvdata
*
drvdata
=
hid_get_drvdata
(
hdev
);
unsigned
long
flags
;
if
(
drvdata
->
kbd_backlight
)
{
if
(
drvdata
->
kbd_backlight
)
{
spin_lock_irqsave
(
&
drvdata
->
kbd_backlight
->
lock
,
flags
);
drvdata
->
kbd_backlight
->
removed
=
true
;
drvdata
->
kbd_backlight
->
removed
=
true
;
spin_unlock_irqrestore
(
&
drvdata
->
kbd_backlight
->
lock
,
flags
);
cancel_work_sync
(
&
drvdata
->
kbd_backlight
->
work
);
cancel_work_sync
(
&
drvdata
->
kbd_backlight
->
work
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录