Skip to content

Commit 7b7dfe4

Browse files
stonezdmgregkh
authored andcommitted
tty: n_gsm: fix sleep-in-atomic-context bug in gsm_control_send
The function gsm_dlci_t1() is a timer handler that runs in an atomic context, but it calls "kzalloc(..., GFP_KERNEL)" that may sleep. As a result, the sleep-in-atomic-context bug will happen. The process is shown below: gsm_dlci_t1() gsm_dlci_open() gsm_modem_update() gsm_modem_upd_via_msc() gsm_control_send() kzalloc(sizeof(.., GFP_KERNEL) //may sleep This patch changes the gfp_t parameter of kzalloc() from GFP_KERNEL to GFP_ATOMIC in order to mitigate the bug. Fixes: e1eaea4 ("tty: n_gsm line discipline") Signed-off-by: Duoming Zhou <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 15743ae commit 7b7dfe4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/tty/n_gsm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1711,7 +1711,7 @@ static struct gsm_control *gsm_control_send(struct gsm_mux *gsm,
17111711
unsigned int command, u8 *data, int clen)
17121712
{
17131713
struct gsm_control *ctrl = kzalloc(sizeof(struct gsm_control),
1714-
GFP_KERNEL);
1714+
GFP_ATOMIC);
17151715
unsigned long flags;
17161716
if (ctrl == NULL)
17171717
return NULL;

0 commit comments

Comments
 (0)