Skip to contentSkip to conversation

tty: n_gsm: Debug output allocation must use GFP_ATOMIC

PATCH In review Tony Lindgren 2 participants 2 messages May 23, 2022 – May 25, 2022 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tty: n_gsm: Debug output allocation must use GFP_ATOMIC

Dan Carpenter <[email protected]> reported the following Smatch warning:

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

This is because gsm_control_message() is holding a spin lock so gsm_hex_dump_bytes() needs to use GFP_ATOMIC instead of GFP_KERNEL.

Fixes 925ea0fa5277 ("tty: n_gsm: Fix packet data hex dump output")
---
 drivers/tty/n_gsm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/n_gsm.c +1 -1
@@ -459,7 +459,7 @@ static void gsm_hex_dump_bytes(const char *fname, const u8 *data,
 		return;
 	}
 
-	prefix = kasprintf(GFP_KERNEL, "%s: ", fname);
+	prefix = kasprintf(GFP_ATOMIC, "%s: ", fname);
 	if (!prefix)
 		return;
 	print_hex_dump(KERN_INFO, prefix, DUMP_PREFIX_OFFSET, 16, 1, data, len,
Signature · 1 line
2.36.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Tony Lindgren

Dan Carpenter <[email protected]> reported the following Smatch warning:

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

Quoted 6 lines

This is because gsm_control_message() is holding a spin lock so gsm_hex_dump_bytes() needs to use GFP_ATOMIC instead of GFP_KERNEL.

Fixes 925ea0fa5277 ("tty: n_gsm: Fix packet data hex dump output")
Quoted 18 lines
---
 drivers/tty/n_gsm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/n_gsm.c +1 -1
@@ -459,7 +459,7 @@ static void gsm_hex_dump_bytes(const char *fname, const u8 *data,
 		return;
 	}
 
-	prefix = kasprintf(GFP_KERNEL, "%s: ", fname);
+	prefix = kasprintf(GFP_ATOMIC, "%s: ", fname);
 	if (!prefix)
 		return;
 	print_hex_dump(KERN_INFO, prefix, DUMP_PREFIX_OFFSET, 16, 1, data, len,
Signature · 1 line
2.36.1
Signature · 3 lines
Gregory Clement, Bootlin
Embedded Linux and Kernel engineering
http://bootlin.com