Skip to contentSkip to conversation

arch: x86: platform: mrst: pr_err() need notice that 'sdev->modalias' may not a NUL terminated string.

PATCH In review Chen Gang 2 participants 3 messages May 26, 2013 – May 27, 2013

Subsystems (2)
lore
Share & tools
lore

Chen Gang

author
#0 lore raw

PATCH 1/1 arch: x86: platform: mrst: pr_err() need notice that 'sdev->modalias' may not a NUL terminated string.

According to the areas which use "%16.16s" within this file, the 'sdev->modalias' may not always be a NUL terminated string.

So need use "%.16s" instead of "%s" in pr_err(), or may cause issue.

---
 arch/x86/platform/mrst/mrst.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/platform/mrst/mrst.c +1 -1
index a0a0a43..e2e069c 100644
@@ -746,7 +746,7 @@ static void __init intel_scu_spi_device_register(struct spi_board_info *sdev)
 
 	new_dev = kzalloc(sizeof(*sdev), GFP_KERNEL);
 	if (!new_dev) {
-		pr_err("failed to alloc mem for delayed spi dev %s\n",
+		pr_err("failed to alloc mem for delayed spi dev %.16s\n",
 			sdev->modalias);
 		return;
 	}
Signature · 1 line
1.7.7.6
#1 lore raw
Quoted 5 lines · Chen Gang

According to the areas which use "%16.16s" within this file, the 'sdev->modalias' may not always be a NUL terminated string.

So need use "%.16s" instead of "%s" in pr_err(), or may cause issue.

No. spi_match_id() expects a NULL terminated string and I would be suprised if it would be otherwise. Therefore moorsetown or this files has to learn to NULL terminate its strings.

Quoted 1 line

Sebastian

author
#2 lore raw
Quoted 10 lines · Sebastian Andrzej Siewior
Quoted 5 lines · Chen Gang
Quoted 5 lines

According to the areas which use "%16.16s" within this file, the 'sdev->modalias' may not always be a NUL terminated string.

So need use "%.16s" instead of "%s" in pr_err(), or may cause issue.

No. spi_match_id() expects a NULL terminated string and I would be suprised if it would be otherwise. Therefore moorsetown or this files has to learn to NULL terminate its strings.

In spi_match_id(), it is 'spi_device', not 'spi_board_info'. ;-)

But all together, it is my fault, the original implementation has no
issue: "I treated SFI_NAME_LEN as SPI_NAME_LEN when strncpy()".

BTW: 'pentry->name' in sfi_parse_devs() may not always be a NUL terminated string, could you give a check, too ? ;-)

Thanks.

Signature · 3 lines
Chen Gang

Asianux Corporation