Skip to content

Commit f4ac050

Browse files
lsgunthkelvin-cao
authored andcommitted
PCI/switchtec: Fix init_completion race condition with poll_wait()
The call to init_completion() in mrpc_queue_cmd() can theoretically race with the call to poll_wait() in switchtec_dev_poll(). poll() write() switchtec_dev_poll() switchtec_dev_write() poll_wait(&s->comp.wait); mrpc_queue_cmd() init_completion(&s->comp) init_waitqueue_head(&s->comp.wait) To my knowledge, no one has hit this bug. Fix this by using reinit_completion() instead of init_completion() in mrpc_queue_cmd(). Fixes: 080b47def5e5 ("MicroSemi Switchtec management interface driver") Reported-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Logan Gunthorpe <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Bjorn Helgaas <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 31e9376 commit f4ac050

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

switchtec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ static int mrpc_queue_cmd(struct switchtec_user *stuser)
191191
kref_get(&stuser->kref);
192192
stuser->read_len = sizeof(stuser->data);
193193
stuser_set_state(stuser, MRPC_QUEUED);
194-
init_completion(&stuser->comp);
194+
reinit_completion(&stuser->comp);
195195
list_add_tail(&stuser->list, &stdev->mrpc_queue);
196196

197197
mrpc_cmd_submit(stdev);

0 commit comments

Comments
 (0)