Skip to contentSkip to conversation

ARM: mv78xx0: fix possible PCI buffer overflow

PATCH In review Arnd Bergmann 2 participants 2 messages Jan 11, 2017 – Jan 13, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: mv78xx0: fix possible PCI buffer overflow

gcc-7.0 reports a potential array overflow:

arch/arm/mach-mv78xx0/pcie.c: In function 'mv78xx0_pcie_preinit':
arch/arm/mach-mv78xx0/pcie.c:81:4: error: output may be truncated before the last format character [-Werror=format-truncation=]

I haven't checked if this can actually happen, but making the array one 32-bit word longer addresses the warning and makes it completely safe.

---
 arch/arm/mach-mv78xx0/pcie.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-mv78xx0/pcie.c +1 -1
index 13a7d72ee0c4..81ff4327a962 100644
@@ -29,7 +29,7 @@ struct pcie_port {
 	u8			root_bus_nr;
 	void __iomem		*base;
 	spinlock_t		conf_lock;
-	char			mem_space_name[16];
+	char			mem_space_name[20];
 	struct resource		res;
 };
 
Signature · 1 line
2.9.0
#1 lore raw

Hi Arnd,

Quoted 10 lines · Arnd Bergmann

gcc-7.0 reports a potential array overflow:

arch/arm/mach-mv78xx0/pcie.c: In function 'mv78xx0_pcie_preinit':
arch/arm/mach-mv78xx0/pcie.c:81:4: error: output may be truncated before the last format character [-Werror=format-truncation=]

I haven't checked if this can actually happen, but making the array one 32-bit word longer addresses the warning and makes it completely safe.

Applied on mvebu/soc

Thanks,

Gregory

Quoted 20 lines
---
 arch/arm/mach-mv78xx0/pcie.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-mv78xx0/pcie.c +1 -1
index 13a7d72ee0c4..81ff4327a962 100644
@@ -29,7 +29,7 @@ struct pcie_port {
 	u8			root_bus_nr;
 	void __iomem		*base;
 	spinlock_t		conf_lock;
-	char			mem_space_name[16];
+	char			mem_space_name[20];
 	struct resource		res;
 };
 
Signature · 1 line
2.9.0
Signature · 4 lines
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com