net: nfc: nci: Fix a sleep-in-atomic-context bug in nci_uart_default_recv_buf()
Subsystems (3)
PATCH 1/1 net: nfc: nci: Fix a sleep-in-atomic-context bug in nci_uart_default_recv_buf()
The kernel module may sleep with holding a spinlock.
The function call paths (from bottom to top) in Linux-4.16 are:
[FUNC] nci_skb_alloc(GFP_KERNEL)net/nfc/nci/uart.c, 349:
nci_skb_alloc in nci_uart_default_recv_bufnet/nfc/nci/uart.c, 255:
[FUNC_PTR]nci_uart_default_recv_buf in nci_uart_tty_receivenet/nfc/nci/uart.c, 254:
spin_lock in nci_uart_tty_receive
Note that [FUNC_PTR] means a function pointer call is used.
To fix this bug, GFP_KERNEL is replaced with GFP_ATOMIC.
This bug is found by my static analysis tool DSAC.
Signed-off-by Jia-Ju Bai <[email protected]>
--- net/nfc/nci/uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/nfc/nci/uart.c +1 -1
@@ -348,7 +348,7 @@ static int nci_uart_default_recv_buf(struct nci_uart *nu, const u8 *data, nu->rx_packet_len =-1 ; nu->rx_skb =nci_skb_alloc (nu->ndev,NCI_MAX_PACKET_SIZE , -GFP_KERNEL ); +GFP_ATOMIC );if (!nu->rx_skb)return -ENOMEM ; }
Signature · 1 line
2.17.0