* [PATCH] pcmcia: fix setting of kthread task states
@ 2022-01-09 20:14 Dominik Brodowski
2022-01-09 20:22 ` Matthew Wilcox
0 siblings, 1 reply; 2+ messages in thread
From: Dominik Brodowski @ 2022-01-09 20:14 UTC (permalink / raw)
To: linux-kernel; +Cc: Matthew Wilcox, Greg Kroah-Hartman, Al Viro
We need to set TASK_INTERRUPTIBLE before calling kthread_should_stop().
Otherwise, kthread_stop() might see that the pccardd thread is still
in TASK_RUNNING state and fail to wake it up.
Additonally, we only need to set the state back to TASK_RUNNING if
kthread_should_stop() breaks the loop.
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reported-by: Al Viro <viro@ZenIV.linux.org.uk>
Fixes: d3046ba809ce ("pcmcia: fix a boot time warning in pcmcia cs code")
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
---
drivers/pcmcia/cs.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index e211e2619680..f70197154a36 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -666,18 +666,16 @@ static int pccardd(void *__skt)
if (events || sysfs_events)
continue;
+ set_current_state(TASK_INTERRUPTIBLE);
if (kthread_should_stop())
break;
- set_current_state(TASK_INTERRUPTIBLE);
-
schedule();
- /* make sure we are running */
- __set_current_state(TASK_RUNNING);
-
try_to_freeze();
}
+ /* make sure we are running before we exit */
+ __set_current_state(TASK_RUNNING);
/* shut down socket, if a device is still present */
if (skt->state & SOCKET_PRESENT) {
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] pcmcia: fix setting of kthread task states
2022-01-09 20:14 [PATCH] pcmcia: fix setting of kthread task states Dominik Brodowski
@ 2022-01-09 20:22 ` Matthew Wilcox
0 siblings, 0 replies; 2+ messages in thread
From: Matthew Wilcox @ 2022-01-09 20:22 UTC (permalink / raw)
To: Dominik Brodowski; +Cc: linux-kernel, Greg Kroah-Hartman, Al Viro
On Sun, Jan 09, 2022 at 09:14:15PM +0100, Dominik Brodowski wrote:
> We need to set TASK_INTERRUPTIBLE before calling kthread_should_stop().
> Otherwise, kthread_stop() might see that the pccardd thread is still
> in TASK_RUNNING state and fail to wake it up.
>
> Additonally, we only need to set the state back to TASK_RUNNING if
> kthread_should_stop() breaks the loop.
>
> Cc: Matthew Wilcox <willy@infradead.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Reported-by: Al Viro <viro@ZenIV.linux.org.uk>
> Fixes: d3046ba809ce ("pcmcia: fix a boot time warning in pcmcia cs code")
> Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-09 20:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-09 20:14 [PATCH] pcmcia: fix setting of kthread task states Dominik Brodowski
2022-01-09 20:22 ` Matthew Wilcox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome