diff options
author | Duoming Zhou <duoming@zju.edu.cn> | 2022-05-18 14:57:33 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2022-05-20 03:54:02 +0300 |
commit | b413b0cb008646e9f24ce5253cb3cf7ee217aff6 (patch) | |
tree | 714c44985ca40de1a3b9a2299dcc424578ae81b8 /drivers/nfc/st21nfca/st21nfca.h | |
parent | 582a2dbc72ac5dd2b3ae4f75bccd4b4c73bb0e1f (diff) | |
download | linux-b413b0cb008646e9f24ce5253cb3cf7ee217aff6.tar.xz |
NFC: hci: fix sleep in atomic context bugs in nfc_hci_hcp_message_tx
There are sleep in atomic context bugs when the request to secure
element of st21nfca is timeout. The root cause is that kzalloc and
alloc_skb with GFP_KERNEL parameter and mutex_lock are called in
st21nfca_se_wt_timeout which is a timer handler. The call tree shows
the execution paths that could lead to bugs:
(Interrupt context)
st21nfca_se_wt_timeout
nfc_hci_send_event
nfc_hci_hcp_message_tx
kzalloc(..., GFP_KERNEL) //may sleep
alloc_skb(..., GFP_KERNEL) //may sleep
mutex_lock() //may sleep
This patch moves the operations that may sleep into a work item.
The work item will run in another kernel thread which is in
process context to execute the bottom half of the interrupt.
So it could prevent atomic context from sleeping.
Fixes: 2130fb97fecf ("NFC: st21nfca: Adding support for secure element")
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20220518115733.62111-1-duoming@zju.edu.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/nfc/st21nfca/st21nfca.h')
-rw-r--r-- | drivers/nfc/st21nfca/st21nfca.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/nfc/st21nfca/st21nfca.h b/drivers/nfc/st21nfca/st21nfca.h index cb6ad916be91..ae6771cc9894 100644 --- a/drivers/nfc/st21nfca/st21nfca.h +++ b/drivers/nfc/st21nfca/st21nfca.h @@ -141,6 +141,7 @@ struct st21nfca_se_info { se_io_cb_t cb; void *cb_context; + struct work_struct timeout_work; }; struct st21nfca_hci_info { |