* [PATCH] usb: gadget: f_fs: Fix -Wformat-truncation in proxy endpoint names
@ 2026-07-24 21:56 Neill Kapron
0 siblings, 0 replies; only message in thread
From: Neill Kapron @ 2026-07-24 21:56 UTC (permalink / raw)
To: Greg Kroah-Hartman, Neill Kapron
Cc: kernel-team, kernel test robot, linux-usb, linux-kernel
When using the functionfs rw_proxy feature, proxy endpoint names are
generated by appending "_rw" to the base endpoint name. The base
endpoint name is copied via `snprintf` into an 8-byte buffer
(`comp->name`). On some architectures (e.g., s390), the compiler flags
a `-Wformat-truncation` warning because `%s_rw` could potentially
overflow if the source string is unexpectedly long.
Fix this by specifying a maximum field width of 4 characters
when formatting the endpoint name string. This guarantees that at most
4 characters plus the 3 characters "_rw" (and null terminator) will be
written, fitting within the 8-byte limit.
Note that this is purely to address the compiler static analysis. In
practice, `FFS_MAX_EPS_COUNT` is limited to 31, meaning the longest
possible base endpoint name is "ep30", and therefore the resulting
proxy name, "ep30_rw", is exactly 7 characters.
Fixes: 0f0ea552cd21 ("usb: gadget: f_fs: Introduce rw_proxy file descriptors")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202607111052.PRRGX3Jq-lkp@intel.com/
Assisted-by: Antigravity:gemini-3.1-pro
Signed-off-by: Neill Kapron <nkapron@google.com>
---
drivers/usb/gadget/function/f_fs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 073c4cbd90fb..3f0b445aba19 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -2441,7 +2441,7 @@ static int ffs_epfiles_create(struct ffs_data *ffs)
mutex_init(&comp->mutex);
mutex_init(&comp->dmabufs_mutex);
INIT_LIST_HEAD(&comp->dmabufs);
- snprintf(comp->name, sizeof(comp->name), "%s_rw",
+ snprintf(comp->name, sizeof(comp->name), "%.4s_rw",
epfiles[i].name);
err = ffs_sb_create_file(ffs->sb, comp->name,
comp, &ffs_epfile_operations);
--
2.55.0.229.g6434b31f56-goog
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-07-24 21:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-24 21:56 [PATCH] usb: gadget: f_fs: Fix -Wformat-truncation in proxy endpoint names Neill Kapron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox