Skip to content

Commit d5fa1fe

Browse files
committed
Input: cyapa - add missing input core locking to suspend/resume functions
jira LE-1907 cve CVE-2023-52884 Rebuild_History Non-Buildable kernel-5.14.0-427.37.1.el9_4 commit-author Marek Szyprowski <m.szyprowski@samsung.com> commit 7b4e0b3 Grab input->mutex during suspend/resume functions like it is done in other input drivers. This fixes the following warning during system suspend/resume cycle on Samsung Exynos5250-based Snow Chromebook: ------------[ cut here ]------------ WARNING: CPU: 1 PID: 1680 at drivers/input/input.c:2291 input_device_enabled+0x68/0x6c Modules linked in: ... CPU: 1 PID: 1680 Comm: kworker/u4:12 Tainted: G W 6.6.0-rc5-next-20231009 #14109 Hardware name: Samsung Exynos (Flattened Device Tree) Workqueue: events_unbound async_run_entry_fn unwind_backtrace from show_stack+0x10/0x14 show_stack from dump_stack_lvl+0x58/0x70 dump_stack_lvl from __warn+0x1a8/0x1cc __warn from warn_slowpath_fmt+0x18c/0x1b4 warn_slowpath_fmt from input_device_enabled+0x68/0x6c input_device_enabled from cyapa_gen3_set_power_mode+0x13c/0x1dc cyapa_gen3_set_power_mode from cyapa_reinitialize+0x10c/0x15c cyapa_reinitialize from cyapa_resume+0x48/0x98 cyapa_resume from dpm_run_callback+0x90/0x298 dpm_run_callback from device_resume+0xb4/0x258 device_resume from async_resume+0x20/0x64 async_resume from async_run_entry_fn+0x40/0x15c async_run_entry_fn from process_scheduled_works+0xbc/0x6a8 process_scheduled_works from worker_thread+0x188/0x454 worker_thread from kthread+0x108/0x140 kthread from ret_from_fork+0x14/0x28 Exception stack(0xf1625fb0 to 0xf1625ff8) ... ---[ end trace 0000000000000000 ]--- ... ------------[ cut here ]------------ WARNING: CPU: 1 PID: 1680 at drivers/input/input.c:2291 input_device_enabled+0x68/0x6c Modules linked in: ... CPU: 1 PID: 1680 Comm: kworker/u4:12 Tainted: G W 6.6.0-rc5-next-20231009 #14109 Hardware name: Samsung Exynos (Flattened Device Tree) Workqueue: events_unbound async_run_entry_fn unwind_backtrace from show_stack+0x10/0x14 show_stack from dump_stack_lvl+0x58/0x70 dump_stack_lvl from __warn+0x1a8/0x1cc __warn from warn_slowpath_fmt+0x18c/0x1b4 warn_slowpath_fmt from input_device_enabled+0x68/0x6c input_device_enabled from cyapa_gen3_set_power_mode+0x13c/0x1dc cyapa_gen3_set_power_mode from cyapa_reinitialize+0x10c/0x15c cyapa_reinitialize from cyapa_resume+0x48/0x98 cyapa_resume from dpm_run_callback+0x90/0x298 dpm_run_callback from device_resume+0xb4/0x258 device_resume from async_resume+0x20/0x64 async_resume from async_run_entry_fn+0x40/0x15c async_run_entry_fn from process_scheduled_works+0xbc/0x6a8 process_scheduled_works from worker_thread+0x188/0x454 worker_thread from kthread+0x108/0x140 kthread from ret_from_fork+0x14/0x28 Exception stack(0xf1625fb0 to 0xf1625ff8) ... ---[ end trace 0000000000000000 ]--- Fixes: d69f0a4 ("Input: use input_device_enabled()") Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Reviewed-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com> Link: https://lore.kernel.org/r/20231009121018.1075318-1-m.szyprowski@samsung.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> (cherry picked from commit 7b4e0b3) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 11b3f5e commit d5fa1fe

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/input/mouse/cyapa.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1357,10 +1357,16 @@ static int __maybe_unused cyapa_suspend(struct device *dev)
13571357
u8 power_mode;
13581358
int error;
13591359

1360-
error = mutex_lock_interruptible(&cyapa->state_sync_lock);
1360+
error = mutex_lock_interruptible(&cyapa->input->mutex);
13611361
if (error)
13621362
return error;
13631363

1364+
error = mutex_lock_interruptible(&cyapa->state_sync_lock);
1365+
if (error) {
1366+
mutex_unlock(&cyapa->input->mutex);
1367+
return error;
1368+
}
1369+
13641370
/*
13651371
* Runtime PM is enable only when device is in operational mode and
13661372
* users in use, so need check it before disable it to
@@ -1395,6 +1401,8 @@ static int __maybe_unused cyapa_suspend(struct device *dev)
13951401
cyapa->irq_wake = (enable_irq_wake(client->irq) == 0);
13961402

13971403
mutex_unlock(&cyapa->state_sync_lock);
1404+
mutex_unlock(&cyapa->input->mutex);
1405+
13981406
return 0;
13991407
}
14001408

@@ -1404,6 +1412,7 @@ static int __maybe_unused cyapa_resume(struct device *dev)
14041412
struct cyapa *cyapa = i2c_get_clientdata(client);
14051413
int error;
14061414

1415+
mutex_lock(&cyapa->input->mutex);
14071416
mutex_lock(&cyapa->state_sync_lock);
14081417

14091418
if (device_may_wakeup(dev) && cyapa->irq_wake) {
@@ -1422,6 +1431,7 @@ static int __maybe_unused cyapa_resume(struct device *dev)
14221431
enable_irq(client->irq);
14231432

14241433
mutex_unlock(&cyapa->state_sync_lock);
1434+
mutex_unlock(&cyapa->input->mutex);
14251435
return 0;
14261436
}
14271437

0 commit comments

Comments
 (0)