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

From: Krzysztof Wilczyński
Date: Fri May 17 2024 - 07:29:44 EST


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