OpenCloudOS-Kernel/drivers/nfc/st21nfca
Duoming Zhou b413b0cb00 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: 2130fb97fe ("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>
2022-05-19 17:54:02 -07:00
..
Kconfig treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
core.c nfc: st21nfca: remove unused header includes 2021-08-26 09:13:36 +01:00
dep.c NFC: st21nfca: remove unnecessary variable and labels 2021-05-20 15:44:27 -07:00
i2c.c nfc: st21nfca: remove unnecessary skb check before kfree_skb() 2022-03-18 21:41:51 -07:00
se.c NFC: hci: fix sleep in atomic context bugs in nfc_hci_hcp_message_tx 2022-05-19 17:54:02 -07:00
st21nfca.h NFC: hci: fix sleep in atomic context bugs in nfc_hci_hcp_message_tx 2022-05-19 17:54:02 -07:00
vendor_cmds.c nfc: use *_set_vendor_cmds() helpers 2022-01-27 13:53:26 +00:00