Skip to content

Commit

Permalink
pcmcia: fix setting of kthread task states
Browse files Browse the repository at this point in the history
[ Upstream commit fbb3485f1f931102d8ba606f1c28123f5b48afa3 ]

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.

Additionally, we only need to set the state back to TASK_RUNNING if
kthread_should_stop() breaks the loop.

Cc: Greg Kroah-Hartman <[email protected]>
Reported-by: Al Viro <[email protected]>
Reviewed-by: Matthew Wilcox (Oracle) <[email protected]>
Fixes: d3046ba ("pcmcia: fix a boot time warning in pcmcia cs code")
Signed-off-by: Dominik Brodowski <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
Dominik Brodowski authored and gregkh committed Jan 27, 2022
1 parent 8155aaa commit 133f940
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions drivers/pcmcia/cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,18 +665,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) {
Expand Down

0 comments on commit 133f940

Please sign in to comment.