Commit f854062a authored by Armin Wolf's avatar Armin Wolf Committed by Zheng Zengkai
Browse files

hwmon: (adt7470) Fix warning on module removal

stable inclusion
from stable-v5.10.115
commit ad87f8498ea27e587a09b9fd5c2329ef4c98b7fc
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5IZ9C

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=ad87f8498ea27e587a09b9fd5c2329ef4c98b7fc



--------------------------------

commit 7b2666ce upstream.

When removing the adt7470 module, a warning might be printed:

do not call blocking ops when !TASK_RUNNING; state=1
set at [<ffffffffa006052b>] adt7470_update_thread+0x7b/0x130 [adt7470]

This happens because adt7470_update_thread() can leave the kthread in
TASK_INTERRUPTIBLE state when the kthread is being stopped before
the call of set_current_state(). Since kthread_exit() might sleep in
exit_signals(), the warning is printed.
Fix that by using schedule_timeout_interruptible() and removing
the call of set_current_state().
This causes TASK_INTERRUPTIBLE to be set after kthread_should_stop()
which might cause the kthread to exit.

Reported-by: default avatarZheyu Ma <zheyuma97@gmail.com>
Fixes: 93cacfd4 (hwmon: (adt7470) Allow faster removal)
Signed-off-by: default avatarArmin Wolf <W_Armin@gmx.de>
Tested-by: default avatarZheyu Ma <zheyuma97@gmail.com>
Link: https://lore.kernel.org/r/20220407101312.13331-1-W_Armin@gmx.de


Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
parent b27eea44
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment