Commit 563585ec4bf1319f193c2f51682985bcae400cb4
1 parent
3c6c0d6ca3
Exists in
master
and in
7 other branches
[SCSI] qla2xxx: Fix race that could hang kthread_stop()
There is a small race window in qla2x00_do_dpc() between checking for kthread_should_stop() and going to sleep after setting TASK_INTERRUPTIBLE. If qla2x00_free_device() is called in this window, kthread_stop will wait forever because there will be no one to wake up the process. Fix by making sure we only set TASK_INTERRUPTIBLE before checking kthread_stop(). Reported-by: Bandan Das <bandan.das@stratus.com> Acked-by: Madhuranath Iyengar <Madhu.Iyengar@qlogic.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Showing 1 changed file with 3 additions and 1 deletions Side-by-side Diff
drivers/scsi/qla2xxx/qla_os.c
| ... | ... | @@ -3282,10 +3282,10 @@ |
| 3282 | 3282 | |
| 3283 | 3283 | set_user_nice(current, -20); |
| 3284 | 3284 | |
| 3285 | + set_current_state(TASK_INTERRUPTIBLE); | |
| 3285 | 3286 | while (!kthread_should_stop()) { |
| 3286 | 3287 | DEBUG3(printk("qla2x00: DPC handler sleeping\n")); |
| 3287 | 3288 | |
| 3288 | - set_current_state(TASK_INTERRUPTIBLE); | |
| 3289 | 3289 | schedule(); |
| 3290 | 3290 | __set_current_state(TASK_RUNNING); |
| 3291 | 3291 | |
| 3292 | 3292 | |
| ... | ... | @@ -3454,7 +3454,9 @@ |
| 3454 | 3454 | qla2x00_do_dpc_all_vps(base_vha); |
| 3455 | 3455 | |
| 3456 | 3456 | ha->dpc_active = 0; |
| 3457 | + set_current_state(TASK_INTERRUPTIBLE); | |
| 3457 | 3458 | } /* End of while(1) */ |
| 3459 | + __set_current_state(TASK_RUNNING); | |
| 3458 | 3460 | |
| 3459 | 3461 | DEBUG(printk("scsi(%ld): DPC handler exiting\n", base_vha->host_no)); |
| 3460 | 3462 |