Use a precision specifier in snprintf to ensure the generated string fits within the ETH_GSTRING_LEN (32 bytes) buffer. Signed-off-by: Sean Chang --- v2: - Split the original treewide patch into subsystem-specific commits. - Added more detailed commit descriptions to satisfy checkpatch. drivers/net/ethernet/cadence/macb_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 43cd013bb70e..26f9ccadd9f6 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -3159,8 +3159,8 @@ static void gem_get_ethtool_strings(struct net_device *dev, u32 sset, u8 *p) for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) { for (i = 0; i < QUEUE_STATS_LEN; i++, p += ETH_GSTRING_LEN) { - snprintf(stat_string, ETH_GSTRING_LEN, "q%d_%s", - q, queue_statistics[i].stat_string); + snprintf(stat_string, ETH_GSTRING_LEN, "q%u_%.19s", + q, queue_statistics[i].stat_string); memcpy(p, stat_string, ETH_GSTRING_LEN); } } -- 2.34.1