From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=111.22.67.139 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796377704; b=rKdCsJ9+pYZPmnzY+TdDt4A6WydStYmQjhtduKu3XJPE3HgCPXTt8ip8++L7WSl0jRpF Sb8p2FVtZ3QiWvcdZuNNfmxsHXiNIO/4hOBR9jnjauiOj3KobGSR9Ad2rQe486fx41fVt XcTGgbsrTelMMB+qhqtG03d3U1Z9QdccXMfPGTrcax2mnXePo0xOtOHfBp/O9kn2dPSdg vw0LJUCvxAhPtsEenakFbSuT9TcdI3NNwvS6b4txdFzoPbW36iQ1F0B8GoT7D4Za2wCUq MrWEDfhgd+alxz0gkYBvychRQ5q09Txc6mJBBV98hYUtxWMyW+mjQ+7HxIBP0V7rhGQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796377704; h=DMARC-Filter:DKIM-Signature:X-RM-TagInfo:X-RM-SPAM-FLAG:Received: X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:X-RM-TRANSID:From: To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=DRITGC5He4D8cjOFdqNLxnXmnX+wyvPsgAeN6fcQ+PU=; b=salNukfX6Il9KYMJ6rfR2pGOWjjZAlmeyiFm7BfshaDN6vo4jUO7tlyDcoTWym5oKJne w6ci25H8dj5RkgV6S0dFi+TnLzSoJex0j+YQ7Alf+uUHI2W4L7PkgQM/ckyFAt9lnGoJp EltJiWeWArf0DLj0ujmdViiY0EZmVmIKTziKJ7lJpqJrlVmj3knnEfiDBglQ7+UCeamSF D62Jq2olJ/IE3hL6QZ8eAUhThAYVeM0mXkjxFwlnwNpUcH4+h6Df06rxeN3ZAwdULHh3u hg4+NG1lfDqJGMwv10Z+eXYmQyedSbw61/3YEUBHX1vvQ5cNL1TBpJSopAHv4KmnjwQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=cmss.chinamobile.com; spf=pass smtp.mailfrom=cmss.chinamobile.com; dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=LZ4ScvOZ; arc=none smtp.remote-ip=111.22.67.139 Received: from cmccmta6.chinamobile.com (cmccmta6.chinamobile.com [111.22.67.139]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0AEB5606A322; Fri, 4 Dec 2026 09:48:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0AEB5606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmss.chinamobile.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmss.chinamobile.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=LZ4ScvOZ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmss.chinamobile.com; s=default; l=0; h=from:subject:message-id:to:cc:mime-version; bh=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=; b=LZ4ScvOZwLsT1PDOD9JPkn0XebwPE6F0+aSaQU+lDBqjaRPxMNXCWh6sH5ovdlD/3DDoPwNXVKwvb 1KXvsxuccbyZlQ5fg3DGP3z1hXIwh6SeHFOsAYi6TQcab83mmcuMlGt+0QWc4Uj+1ysRngQTMUtxgm YOZpOR0NuVzEsziY= X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG:00000000 Received:from spf.mail.chinamobile.com (unknown[10.188.0.87]) by rmmx-syy-dmz-app01-12001 (RichMail) with SMTP id 2ee16b128c5c9a7-81f8b; Fri, 04 Dec 2026 17:48:19 +0800 (CST) X-RM-TRANSID:2ee16b128c5c9a7-81f8b X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG:00000000 Received:from (unknown[10.55.1.70]) by rmsmtp-syy-appsvr01-12001 (RichMail) with SMTP id 2ee16b128c60479-947f2; Fri, 04 Dec 2026 17:48:19 +0800 (CST) X-RM-TRANSID:2ee16b128c60479-947f2 From: Aibing Chen To: Willem de Bruijn Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 2/2] cxgb4: use scnprintf() for fw_version Date: Fri, 4 Dec 2026 17:48:16 +0800 Message-ID: <20261204094816.116-2-chenaibing@cmss.chinamobile.com> X-Mailer: git-send-email 2.50.1.windows.1 In-Reply-To: <20261204094816.116-1-chenaibing@cmss.chinamobile.com> References: <20261204094816.116-1-chenaibing@cmss.chinamobile.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit get_drvinfo() formats the firmware and TP revisions into info->fw_version, a fixed ETHTOOL_FWVERS_LEN (32) byte field of the ethtool_drvinfo UAPI structure: snprintf(info->fw_version, sizeof(info->fw_version), "%u.%u.%u.%u, TP %u.%u.%u.%u", ...); The eight values are u8, so the format can produce up to 35 bytes; gcc reports it in a W=1 build and CONFIG_WERROR turns it into a build failure: cxgb4_ethtool.c:209:52: error: '%u' directive output may be truncated writing between 1 and 3 bytes into a region of size between 0 and 14 [-Werror=format-truncation=] Use scnprintf(), which returns the number of bytes written, so the string is bounded by the field and the intent is visible at the call site. The ethtool_drvinfo layout is part of the UAPI and cannot be enlarged. Reported-by: kernel test robot Link: https://lore.kernel.org/oe-kbuild-all/202604141419.a4vuNBN7-lkp@intel.com/ Signed-off-by: Aibing Chen --- drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c index 0092bc16f..bba9ca03e 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c @@ -205,8 +205,8 @@ static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) info->regdump_len = get_regs_len(dev); if (adapter->params.fw_vers) - snprintf(info->fw_version, sizeof(info->fw_version), - "%u.%u.%u.%u, TP %u.%u.%u.%u", + scnprintf(info->fw_version, sizeof(info->fw_version), + "%u.%u.%u.%u, TP %u.%u.%u.%u", FW_HDR_FW_VER_MAJOR_G(adapter->params.fw_vers), FW_HDR_FW_VER_MINOR_G(adapter->params.fw_vers), FW_HDR_FW_VER_MICRO_G(adapter->params.fw_vers),