summaryrefslogtreecommitdiff
path: root/drivers/staging/r8188eu/os_dep/os_intfs.c
diff options
context:
space:
mode:
authorFabio M. De Francesco <fmdefrancesco@gmail.com>2021-10-18 18:20:04 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-10-19 09:33:54 +0200
commitd250bf4c397ab8f529ed172a3eb4dab64f700a9d (patch)
tree8fc5646881394956bb7cd4270ba8cd3a035fb367 /drivers/staging/r8188eu/os_dep/os_intfs.c
parent2d68d8ee8fec9c2db1f37ed6fa82255d4e36df4c (diff)
staging: r8188eu: Use completions for signaling start / end kthread
rtw_cmd_thread() "up(s)" a semaphore twice, first to notify callers when its execution is started and then to notify when it is about to end. It makes the same semaphore go "up" twice in the same thread. This construct makes Smatch to warn of duplicate "up(s)". This thread uses interruptible semaphores where instead completions are more suitable. For this purpose it calls an helper (_rtw_down_sema()) that returns values that are never checked. It may lead to bugs. To address the above-mentioned issues, use two completions variables instead of semaphores. Use the uninterruptible versions of wake_for_completion*() because the interruptible / killable versions are not necessary. Tested with "ASUSTek Computer, Inc. Realtek 8188EUS [USB-N10 Nano]". Acked-by: Phillip Potter <phil@philpotter.co.uk> Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com> Link: https://lore.kernel.org/r/20211018162006.5527-2-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/r8188eu/os_dep/os_intfs.c')
-rw-r--r--drivers/staging/r8188eu/os_dep/os_intfs.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c
index e7964a048c99..0bcea66f550b 100644
--- a/drivers/staging/r8188eu/os_dep/os_intfs.c
+++ b/drivers/staging/r8188eu/os_dep/os_intfs.c
@@ -385,7 +385,8 @@ u32 rtw_start_drv_threads(struct adapter *padapter)
if (IS_ERR(padapter->cmdThread))
_status = _FAIL;
else
- _rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema); /* wait for cmd_thread to run */
+ /* wait for rtw_cmd_thread() to start running */
+ wait_for_completion(&padapter->cmdpriv.start_cmd_thread);
return _status;
}
@@ -395,7 +396,8 @@ void rtw_stop_drv_threads(struct adapter *padapter)
/* Below is to termindate rtw_cmd_thread & event_thread... */
up(&padapter->cmdpriv.cmd_queue_sema);
if (padapter->cmdThread)
- _rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema);
+ /* wait for rtw_cmd_thread() to stop running */
+ wait_for_completion(&padapter->cmdpriv.stop_cmd_thread);
}
static u8 rtw_init_default_value(struct adapter *padapter)