All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] tty: n_gsm: Fix packet data hex dump output
@ 2022-05-23  7:01 Dan Carpenter
  2022-05-23  7:34 ` Tony Lindgren
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2022-05-23  7:01 UTC (permalink / raw)
  To: tony; +Cc: kernel-janitors

Hello Tony Lindgren,

The patch 925ea0fa5277: "tty: n_gsm: Fix packet data hex dump output"
from May 12, 2022, leads to the following Smatch static checker
warning:

	drivers/tty/n_gsm.c:720 gsm_data_kick()
	warn: sleeping in atomic context

drivers/tty/n_gsm.c
    698 static void gsm_data_kick(struct gsm_mux *gsm, struct gsm_dlci *dlci)
    699 {
    700         struct gsm_msg *msg, *nmsg;
    701         int len;
    702 
    703         list_for_each_entry_safe(msg, nmsg, &gsm->tx_list, list) {
    704                 if (gsm->constipated && msg->addr)
    705                         continue;
    706                 if (gsm->encoding != 0) {
    707                         gsm->txframe[0] = GSM1_SOF;
    708                         len = gsm_stuff_frame(msg->data,
    709                                                 gsm->txframe + 1, msg->len);
    710                         gsm->txframe[len + 1] = GSM1_SOF;
    711                         len += 2;
    712                 } else {
    713                         gsm->txframe[0] = GSM0_SOF;
    714                         memcpy(gsm->txframe + 1 , msg->data, msg->len);
    715                         gsm->txframe[msg->len + 1] = GSM0_SOF;
    716                         len = msg->len + 2;
    717                 }
    718 
    719                 if (debug & 4)
--> 720                         gsm_hex_dump_bytes(__func__, gsm->txframe, len);

gsm_control_message() is holding a spin lock so gsm_hex_dump_bytes()
might need to use GFP_ATOMIC instead of GFP_KERNEL.

    721                 if (gsmld_output(gsm, gsm->txframe, len) <= 0)
    722                         break;
    723                 /* FIXME: Can eliminate one SOF in many more cases */
    724                 gsm->tx_bytes -= msg->len;
    725 
    726                 list_del(&msg->list);
    727                 kfree(msg);
    728 
    729                 if (dlci) {
    730                         tty_port_tty_wakeup(&dlci->port);
    731                 } else {
    732                         int i = 0;
    733 
    734                         for (i = 0; i < NUM_DLCI; i++)
    735                                 if (gsm->dlci[i])
    736                                         tty_port_tty_wakeup(&gsm->dlci[i]->port);
    737                 }
    738         }
    739 }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] tty: n_gsm: Fix packet data hex dump output
  2022-05-23  7:01 [bug report] tty: n_gsm: Fix packet data hex dump output Dan Carpenter
@ 2022-05-23  7:34 ` Tony Lindgren
  0 siblings, 0 replies; 2+ messages in thread
From: Tony Lindgren @ 2022-05-23  7:34 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: kernel-janitors

Hi,

* Dan Carpenter <dan.carpenter@oracle.com> [220523 06:57]:
> Hello Tony Lindgren,
> 
> The patch 925ea0fa5277: "tty: n_gsm: Fix packet data hex dump output"
> from May 12, 2022, leads to the following Smatch static checker
> warning:
> 
> 	drivers/tty/n_gsm.c:720 gsm_data_kick()
> 	warn: sleeping in atomic context
> 
> drivers/tty/n_gsm.c
>     698 static void gsm_data_kick(struct gsm_mux *gsm, struct gsm_dlci *dlci)
>     699 {
>     700         struct gsm_msg *msg, *nmsg;
>     701         int len;
>     702 
>     703         list_for_each_entry_safe(msg, nmsg, &gsm->tx_list, list) {
>     704                 if (gsm->constipated && msg->addr)
>     705                         continue;
>     706                 if (gsm->encoding != 0) {
>     707                         gsm->txframe[0] = GSM1_SOF;
>     708                         len = gsm_stuff_frame(msg->data,
>     709                                                 gsm->txframe + 1, msg->len);
>     710                         gsm->txframe[len + 1] = GSM1_SOF;
>     711                         len += 2;
>     712                 } else {
>     713                         gsm->txframe[0] = GSM0_SOF;
>     714                         memcpy(gsm->txframe + 1 , msg->data, msg->len);
>     715                         gsm->txframe[msg->len + 1] = GSM0_SOF;
>     716                         len = msg->len + 2;
>     717                 }
>     718 
>     719                 if (debug & 4)
> --> 720                         gsm_hex_dump_bytes(__func__, gsm->txframe, len);
> 
> gsm_control_message() is holding a spin lock so gsm_hex_dump_bytes()
> might need to use GFP_ATOMIC instead of GFP_KERNEL.

OK thanks for the report. I'll send a patch for GFP_ATOMIC later on today.

Regards,

Tony

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-23  8:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-23  7:01 [bug report] tty: n_gsm: Fix packet data hex dump output Dan Carpenter
2022-05-23  7:34 ` Tony Lindgren

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.