staging: r8188eu: Use completions for signaling start / end kthread
authorFabio M. De Francesco <fmdefrancesco@gmail.com>
Mon, 18 Oct 2021 16:20:04 +0000 (18:20 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 19 Oct 2021 07:33:54 +0000 (09:33 +0200)
commitd250bf4c397ab8f529ed172a3eb4dab64f700a9d
tree8fc5646881394956bb7cd4270ba8cd3a035fb367
parent2d68d8ee8fec9c2db1f37ed6fa82255d4e36df4c
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>
drivers/staging/r8188eu/core/rtw_cmd.c
drivers/staging/r8188eu/include/rtw_cmd.h
drivers/staging/r8188eu/os_dep/os_intfs.c