PCI: mt7621: Fix possible string truncation in snprintf
Subsystems (4)
Sergio Paracuellos
maintainerPATCH 1/1 PCI: mt7621: Fix possible string truncation in snprintf
The following warning appears when driver is compiled with W=1.
CC drivers/pci/controller/pcie-mt7621.odrivers/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.
--- drivers/pci/controller/pcie-mt7621.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/pcie-mt7621.c +1 -1
@@ -202,7 +202,7 @@ static int mt7621_pcie_parse_port(struct mt7621_pcie *pcie,struct mt7621_pcie_port *port;struct device *dev = pcie->dev;struct platform_device *pdev =to_platform_device (dev); -char name[10 ]; +char name[11 ];int err; port =devm_kzalloc (dev,sizeof (*port),GFP_KERNEL );
Signature · 1 line
2.25.1
Sergio Paracuellos
maintainerHi,
Quoted 37 lines · Sergio Paracuellos
The following warning appears when driver is compiled with W=1.
CC
drivers/pci/controller/pcie-mt7621.odrivers/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 10228 | snprintf(name, sizeof(name), "pcie-phy%d", slot); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Clean this up increasing destination buffer one byte.
Reported-by Bjorn Helgaas <[email protected]>Signed-off-by Sergio Paracuellos <[email protected]>--- drivers/pci/controller/pcie-mt7621.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/controller/pcie-mt7621.c +1
-2@@ -202,7 +202,7 @@ static int mt7621_pcie_parse_port(struct mt7621_pcie *pcie,struct mt7621_pcie_port *port;struct device *dev = pcie->dev;struct platform_device *pdev =to_platform_device (dev); -char name[10 ]; +char name[11 ];int err; port =devm_kzalloc (dev,sizeof (*port),GFP_KERNEL ); --
Quoted 2 lines
2.25.1
Gentle ping on this patch :)
Thanks,
Sergio Paracuellos
Sergio Paracuellos
maintainerHi,
Quoted 40 lines · Sergio Paracuellos
Hi,
Quoted 35 lines · Sergio Paracuellos
The following warning appears when driver is compiled with W=1.
CC
drivers/pci/controller/pcie-mt7621.odrivers/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 10228 | snprintf(name, sizeof(name), "pcie-phy%d", slot); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Clean this up increasing destination buffer one byte.
Reported-by Bjorn Helgaas <[email protected]>Signed-off-by Sergio Paracuellos <[email protected]>--- drivers/pci/controller/pcie-mt7621.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/controller/pcie-mt7621.c +1
-1@@ -202,7 +202,7 @@ static int mt7621_pcie_parse_port(struct mt7621_pcie *pcie,struct mt7621_pcie_port *port;struct device *dev = pcie->dev;struct platform_device *pdev =to_platform_device (dev); -char name[10 ]; +char name[11 ];int err;
Quoted 6 lines
Quoted 4 lines
drivers/pci/controller/pcie-mt7621.c +0
-1port =devm_kzalloc (dev,sizeof (*port),GFP_KERNEL ); --2.25.1
Gentle ping on this patch :)
Another gentle ping on this patch :)
Thanks,
Sergio Paracuellos
Quoted 10 lines · Sergio Paracuellos
The following warning appears when driver is compiled with W=1.
CC
drivers/pci/controller/pcie-mt7621.odrivers/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
Quoted 8 lines
228 | snprintf(name, sizeof(name), "pcie-phy%d", slot); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Clean this up increasing destination buffer one byte.
Krzysztof applied this to pci/controller/mt7621 for v6.10, thanks! I just pulled that branch into "next", so it should appear in the next linux-next.
Quoted 20 lines
--- drivers/pci/controller/pcie-mt7621.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/controller/pcie-mt7621.c +1
-1@@ -202,7 +202,7 @@ static int mt7621_pcie_parse_port(struct mt7621_pcie *pcie,struct mt7621_pcie_port *port;struct device *dev = pcie->dev;struct platform_device *pdev =to_platform_device (dev); -char name[10 ]; +char name[11 ];int err; port =devm_kzalloc (dev,sizeof (*port),GFP_KERNEL );Signature · 1 line
2.25.1
Sergio Paracuellos
maintainerQuoted 17 lines · Bjorn Helgaas
Quoted 15 lines · Sergio Paracuellos
The following warning appears when driver is compiled with W=1.
CC
drivers/pci/controller/pcie-mt7621.odrivers/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 10228 | snprintf(name, sizeof(name), "pcie-phy%d", slot); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Clean this up increasing destination buffer one byte.
Quoted 7 lines
Quoted 3 lines
Krzysztof applied this to pci/controller/mt7621 for v6.10, thanks! I just pulled that branch into "next", so it should appear in the next linux-next.
Awesome. Thanks for letting me know.
Best regards,
Sergio Paracuellos
Krzysztof Wilczyński
AppliedHello,
Quoted 10 lines
The following warning appears when driver is compiled with W=1.
CC
drivers/pci/controller/pcie-mt7621.odrivers/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
Quoted 4 lines
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