[PATCH] staging: vme_user: prefer snprintf over sprintf in vme_tsi148.c

From: Tomasz Unger

Date: Tue Aug 18 2026 - 13:11:23 EST


Using sprintf has potential for buffer overflows if the formatted
string exceeds the destination buffer size. Replace it with
snprintf, passing the exact buffer size (VMENAMSIZ + 3) that was
allocated with kmalloc() a few lines above, so the write is
always bounded to the actual buffer.

Signed-off-by: Tomasz Unger <tomasz.unger@xxxxxxxx>
---
Verified with checkpatch.pl - no errors or warnings.
Compiled the vme_tsi148 module successfully with CONFIG_VME_TSI148=m
(also required enabling CONFIG_VME_BUS=y, previously disabled).
Module loads without errors in a QEMU environment (verified via
insmod and lsmod, dmesg shows no errors). This confirms the module
loads cleanly but does not exercise the changed code path, which
would require the actual VME hardware.
---
drivers/staging/vme_user/vme_tsi148.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vme_user/vme_tsi148.c b/drivers/staging/vme_user/vme_tsi148.c
index c695ad9b4ca2..bf3589118da9 100644
--- a/drivers/staging/vme_user/vme_tsi148.c
+++ b/drivers/staging/vme_user/vme_tsi148.c
@@ -744,8 +744,8 @@ static int tsi148_alloc_resource(struct vme_master_resource *image,
}
}

- sprintf((char *)image->bus_resource.name, "%s.%d", tsi148_bridge->name,
- image->number);
+ snprintf((char *)image->bus_resource.name, VMENAMSIZ + 3, "%s.%d", tsi148_bridge->name,
+ image->number);

image->bus_resource.start = 0;
image->bus_resource.end = (unsigned long)size;

---
base-commit: 8d3ae59288f1e7d58d76558a6ee96d533bc5019f
change-id: 20260818-vme-tsi148-sprintf-023a79960c19

Best regards,
--
Tomasz Unger <tomasz.unger@xxxxxxxx>