317-brcmfmac-Fix-race-condition-in-msgbuf-ioctl-processi.patch 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. From: Hante Meuleman <[email protected]>
  2. Date: Fri, 6 Mar 2015 18:40:41 +0100
  3. Subject: [PATCH] brcmfmac: Fix race condition in msgbuf ioctl processing.
  4. Msgbuf is using a wait_event_timeout to wait for the response on
  5. an ioctl. The wakeup routine uses waitqueue_active to see if
  6. wait_event_timeout has been called. There is a chance that the
  7. response arrives before wait_event_timeout is called, this
  8. will result in situation that wait_event_timeout never gets
  9. woken again and assumed result will be a timeout. This patch
  10. removes that errornous situation by always setting the
  11. ctl_completed var before checking for queue active.
  12. Reviewed-by: Arend Van Spriel <[email protected]>
  13. Reviewed-by: Pieter-Paul Giesberts <[email protected]>
  14. Signed-off-by: Hante Meuleman <[email protected]>
  15. Signed-off-by: Arend van Spriel <[email protected]>
  16. Signed-off-by: Kalle Valo <[email protected]>
  17. ---
  18. --- a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
  19. +++ b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
  20. @@ -481,10 +481,9 @@ static int brcmf_msgbuf_ioctl_resp_wait(
  21. static void brcmf_msgbuf_ioctl_resp_wake(struct brcmf_msgbuf *msgbuf)
  22. {
  23. - if (waitqueue_active(&msgbuf->ioctl_resp_wait)) {
  24. - msgbuf->ctl_completed = true;
  25. + msgbuf->ctl_completed = true;
  26. + if (waitqueue_active(&msgbuf->ioctl_resp_wait))
  27. wake_up(&msgbuf->ioctl_resp_wait);
  28. - }
  29. }