From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C2F03E2ADF for ; Fri, 24 Jul 2026 21:56:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.197 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784930194; cv=none; b=MsVR+vgPb/3bG5OKLY1qhty+oz+zR+jRIal3xZ2vQBtvtgMATRfHHq0p30YdsayOsrMCKPEmdZ5sLqa4C8LiuPdV/WV1vd8FmWxgh2Ur//cy+5pxaurkIk+djo/HOJdQzcaiT9yH6hualWabea/fpe52x7f5y58Ddd8d2SCGiaE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784930194; c=relaxed/simple; bh=kAWgstcYAXfhOYASQ6fi9LEUKfgTq5CGukshU6txNSU=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=N32Y5nKbxdSpHtreh5pLGByu2wkfLoNM8LWP6sRXz7H6slmmgl8+odeGv6B9DEtHol98N6rnq9Jz3zn4a7W+9xpZ0YrGJrWyP1YbF5guX0J0MFLPXXI+wbOPP08cAHI1zpLWjSKSAEIImIfnd03iV7Ffo1pStm//3+XpLm68igA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--nkapron.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=nQoGdmP7; arc=none smtp.client-ip=209.85.167.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--nkapron.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="nQoGdmP7" Received: by mail-oi1-f197.google.com with SMTP id 5614622812f47-495b8120909so887334b6e.1 for ; Fri, 24 Jul 2026 14:56:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784930184; x=1785534984; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=c/UKAkW4BO4cMyvkKTsk4jsdrcWeqN0nKSN0zDbGXYY=; b=nQoGdmP7rg90bgPPRWXiv1zSCvvcXY64yWVV/14sh7kMneo4rfV+g5PO1pDBz+W2Jq puHqHAKRh6jab7Z7pJUPBri41IlgE8p6jagndOWDuXOg9DPQuxQq2w72oVJmK1dnuzlr cg9y8Ay7ErNrRsaiQbF6e0nKgCTRu4Ge4mwGRMMamembtkNOL7xISunbG2r7A8rGNM/l 8FmGhrkvymEqYCP75d1QjB0TnITK+v2Ew6g9d/YOL23syxabFVmse8kglbVpyNXII4Fl ngA6jd8ihouChVq6N26z6VltimH+Q7X3LicgvRA4xsYJXgr1Vtw4kp93o9gfoEMrWFIr x6Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784930184; x=1785534984; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=c/UKAkW4BO4cMyvkKTsk4jsdrcWeqN0nKSN0zDbGXYY=; b=l3TMHGtmLOZtOE9N7/MH/252SBtbILHGOkBlyb/YoRpTxBA10aRi04oGgVdlMjY3y4 g+bVqgAlQtk6ixAqzzvp9/VG0FeP9yCeVqiZHy6ZKxRmK+4bFdR88o/TqH1JGJafoNGz g2NWZwKVypi94Q8U+3LNfRcZG72irmmnVKYwhR9yTMB2NA+TGifRMlaetQeJTymBP5MW /synRNa/rfCC7Y2fygIsozJkSjnwI1k6r3CFqImc/vB/aTO83yPArI5ipHYW1OI04CGo LAMKvViYZXdQRIZB5gTN/QCDtBgZGKsrv2DyJ6f0ufMd/XY5iX86kof3TTJAXSxIas9L q96w== X-Forwarded-Encrypted: i=1; AHgh+Ro1zkI2RKng4qwF60SXrFYQj8cZgnFRtA5XEFvV5eeRngAdSifMHPVLJEImB4UQ5kT8yvjpe2sk5KU=@vger.kernel.org X-Gm-Message-State: AOJu0Yy2Asd0Q8qCp7Qgs85htMZ5BKAXk58Cklj9ocVMPw0gmbX381HR 3xXkGzLSUoA8Sig5bcuSbMmMLS60H3OjNY4YE1uRVxfrkXZ8dEwQTYQZmPIVDHRoRpsF27T1358 EDiKsoEdhNA== X-Received: from ilbdx20-n1.prod.google.com ([2002:a05:6e02:4214:10b0:506:815:32fa]) (user=nkapron job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6808:1b27:b0:4a0:d9a1:1a94 with SMTP id 5614622812f47-4ab6a13ca4bmr256086b6e.19.1784930184124; Fri, 24 Jul 2026 14:56:24 -0700 (PDT) Date: Fri, 24 Jul 2026 21:56:14 +0000 Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.55.0.229.g6434b31f56-goog Message-ID: <20260724215615.4160303-1-nkapron@google.com> Subject: [PATCH] usb: gadget: f_fs: Fix -Wformat-truncation in proxy endpoint names From: Neill Kapron To: Greg Kroah-Hartman , Neill Kapron Cc: kernel-team@android.com, kernel test robot , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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 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 --- 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