[PATCH] PCI: mt7621: Fix possible string truncation in snprintf

Krzysztof Wilczyński kw at linux.com
Fri May 17 04:29:29 PDT 2024


Hello,

> The following warning appears when driver is compiled with W=1.
> 
> CC      drivers/pci/controller/pcie-mt7621.o
> drivers/pci/controller/pcie-mt7621.c: In function ‘mt7621_pcie_probe’:
> drivers/pci/controller/pcie-mt7621.c:228:49: error: ‘snprintf’ output may
> be truncated before the last format character [-Werror=format-truncation=]
> 228 |         snprintf(name, sizeof(name), "pcie-phy%d", slot);
>     |                                                 ^
> drivers/pci/controller/pcie-mt7621.c:228:9: note: ‘snprintf’ output between
> 10 and 11 bytes into a destination of size 10
> 228 |         snprintf(name, sizeof(name), "pcie-phy%d", slot);
>     |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Clean this up increasing destination buffer one byte.

Applied to controller/mt7621, thank you!

[1/1] PCI: mt7621: Fix string truncation in mt7621_pcie_parse_port()
      https://git.kernel.org/pci/pci/c/fd6eb49a84a8

	Krzysztof



More information about the Linux-mediatek mailing list