WSL2-Linux-Kernel/drivers/net/ethernet
Rahul Rameshbabu 7574b5e65e net/mlx5e: Check return value of snprintf writing to fw_version buffer for representors
[ Upstream commit 1b2bd0c0264febcd8d47209079a6671c38e6558b ]

Treat the operation as an error case when the return value is equivalent to
the size of the name buffer. Failed to write null terminator to the name
buffer, making the string malformed and should not be used. Provide a
string with only the firmware version when forming the string with the
board id fails. This logic for representors is identical to normal flow
with ethtool.

Without check, will trigger -Wformat-truncation with W=1.

    drivers/net/ethernet/mellanox/mlx5/core/en_rep.c: In function 'mlx5e_rep_get_drvinfo':
    drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:78:31: warning: '%.16s' directive output may be truncated writing up to 16 bytes into a region of size between 13 and 22 [-Wformat-truncation=]
      78 |                  "%d.%d.%04d (%.16s)",
         |                               ^~~~~
    drivers/net/ethernet/mellanox/mlx5/core/en_rep.c:77:9: note: 'snprintf' output between 12 and 37 bytes into a destination of size 32
      77 |         snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      78 |                  "%d.%d.%04d (%.16s)",
         |                  ~~~~~~~~~~~~~~~~~~~~~
      79 |                  fw_rev_maj(mdev), fw_rev_min(mdev),
         |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      80 |                  fw_rev_sub(mdev), mdev->board_id);
         |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fixes: cf83c8fdcd ("net/mlx5e: Add missing ethtool driver info for representors")
Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6d4ab2e97dcfbcd748ae71761a9d8e5e41cc732c
Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Link: https://lore.kernel.org/r/20231114215846.5902-16-saeed@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-28 16:56:25 +00:00
..
3com 3c589_cs: Fix an error handling path in tc589_probe() 2023-05-30 13:55:33 +01:00
8390
actions
adaptec
aeroflex ethernet: aeroflex: fix potential skb leak in greth_init_rings() 2022-12-14 11:37:29 +01:00
agere ethernet: use eth_hw_addr_set() instead of ether_addr_copy() 2023-07-27 08:46:59 +02:00
alacritech ethernet: use eth_hw_addr_set() instead of ether_addr_copy() 2023-07-27 08:46:59 +02:00
allwinner ethernet: use of_get_ethdev_address() 2023-07-27 08:47:00 +02:00
alteon
altera ethernet: use of_get_ethdev_address() 2023-07-27 08:47:00 +02:00
amazon eth: remove remaining copies of the NAPI_POLL_WEIGHT define 2023-10-19 23:05:39 +02:00
amd amd-xgbe: fix the false linkup in xgbe_phy_status 2023-06-09 10:32:16 +02:00
apm drivers: net: xgene: disable napi when register irq failed in xgene_enet_open() 2022-11-16 09:58:20 +01:00
apple net: apple: bmac: don't call dev_kfree_skb() under spin_lock_irqsave() 2022-12-31 13:14:19 +01:00
aquantia ethernet: use eth_hw_addr_set() instead of ether_addr_copy() 2023-07-27 08:46:59 +02:00
arc ethernet: use of_get_ethdev_address() 2023-07-27 08:47:00 +02:00
atheros atl1c: Work around the DMA RX overflow issue 2023-11-28 16:56:15 +00:00
broadcom tg3: power down device only on SYSTEM_POWER_OFF 2023-11-20 11:08:29 +01:00
brocade eth: remove remaining copies of the NAPI_POLL_WEIGHT define 2023-10-19 23:05:39 +02:00
cadence ethernet: use of_get_ethdev_address() 2023-07-27 08:47:00 +02:00
calxeda
cavium ethernet: use of_get_ethdev_address() 2023-07-27 08:47:00 +02:00
chelsio chtls: fix tp->rcv_tstamp initialization 2023-11-20 11:08:15 +01:00
cirrus
cisco
cortina net: ethernet: cortina: Fix MTU max setting 2023-11-28 16:56:23 +00:00
davicom
dec
dlink
emulex benet: fix return value check in be_lancer_xmit_workarounds() 2023-08-03 10:22:36 +02:00
ezchip ethernet: use of_get_ethdev_address() 2023-07-27 08:47:00 +02:00
faraday ethernet: use eth_hw_addr_set() instead of ether_addr_copy() 2023-07-27 08:46:59 +02:00
freescale net: enetc: use EXPORT_SYMBOL_GPL for enetc_phc_index 2023-09-06 21:28:37 +01:00
fujitsu
google gve: Use size_add() in call to struct_size() 2023-11-20 11:08:14 +01:00
hisilicon net: hns3: fix VF wrong speed and duplex issue 2023-11-28 16:56:23 +00:00
huawei net: hinic: Fix error handling in hinic_module_init() 2022-11-26 09:24:38 +01:00
i825xx
ibm ibmveth: Remove condition to recompute TCP header checksum. 2023-10-10 21:59:07 +02:00
intel i40e: fix potential memory leaks in i40e_remove() 2023-11-20 11:08:13 +01:00
litex ethernet: use of_get_ethdev_address() 2023-07-27 08:47:00 +02:00
marvell octeontx2-pf: Fix holes in error code 2023-11-20 11:08:28 +01:00
mediatek eth: remove copies of the NAPI_POLL_WEIGHT define 2023-10-19 23:05:34 +02:00
mellanox net/mlx5e: Check return value of snprintf writing to fw_version buffer for representors 2023-11-28 16:56:25 +00:00
micrel ethernet: use of_get_ethdev_address() 2023-07-27 08:47:00 +02:00
microchip ethernet: use eth_hw_addr_set() instead of ether_addr_copy() 2023-07-27 08:46:59 +02:00
microsoft ethernet: use eth_hw_addr_set() instead of ether_addr_copy() 2023-07-27 08:46:59 +02:00
moxa net: moxa: get rid of asymmetry in DMA mapping/unmapping 2022-08-31 17:16:39 +02:00
mscc ethernet: use eth_hw_addr_set() instead of ether_addr_copy() 2023-07-27 08:46:59 +02:00
myricom myri10ge: Fix an error handling path in myri10ge_probe() 2022-12-31 13:14:39 +01:00
natsemi net/sonic: use dma_mapping_error() for error check 2023-03-30 12:47:48 +02:00
neterion ethernet: s2io: don't call dev_kfree_skb() under spin_lock_irqsave() 2022-12-31 13:14:19 +01:00
netronome nfp: flower: avoid rmmod nfp crash issues 2023-10-25 11:58:59 +02:00
ni nixge: fix mac address error handling again 2023-07-27 08:47:05 +02:00
nvidia eth: remove remaining copies of the NAPI_POLL_WEIGHT define 2023-10-19 23:05:39 +02:00
nxp ethernet: use of_get_ethdev_address() 2023-07-27 08:47:00 +02:00
oki-semi net: pch_gbe: fix pci device refcount leak while module exiting 2022-12-02 17:41:05 +01:00
packetengines
pasemi net: pasemi: Fix return type of pasemi_mac_start_tx() 2023-05-24 17:36:45 +01:00
pensando ionic: fix 16bit math issue when PAGE_SIZE >= 64KB 2023-10-06 13:18:05 +02:00
qlogic qed: fix LL2 RX buffer allocation 2023-10-25 11:58:56 +02:00
qualcomm ethernet: use of_get_ethdev_address() 2023-07-27 08:47:00 +02:00
rdc r6040: Fix kmemleak in probe and remove 2022-12-31 13:14:37 +01:00
realtek r8169: respect userspace disabling IFF_MULTICAST 2023-11-20 11:08:29 +01:00
renesas ravb: Fix use-after-free issue in ravb_tx_timeout_work() 2023-10-19 23:05:33 +02:00
rocker ethernet: rocker: fix sleep in atomic context bug in neigh_timer_handler 2022-09-08 12:28:02 +02:00
samsung ethernet: use of_get_ethdev_address() 2023-07-27 08:47:00 +02:00
seeq
sfc ethernet: use eth_hw_addr_set() instead of ether_addr_copy() 2023-07-27 08:46:59 +02:00
sgi
silan
sis
smsc smsc911x: avoid PHY being resumed when interface is not up 2023-04-05 11:24:57 +02:00
socionext net: netsec: Ignore 'phy-mode' on SynQuacer in DT mode 2023-08-11 15:13:53 +02:00
stmicro net: stmmac: fix rx budget limit check 2023-11-28 16:56:24 +00:00
sun cassini: Fix a memory leak in the error handling path of cas_init_one() 2023-05-24 17:36:52 +01:00
synopsys
tehuti
ti eth: remove copies of the NAPI_POLL_WEIGHT define 2023-10-19 23:05:34 +02:00
toshiba net: spider_net: Use size_add() in call to struct_size() 2023-11-20 11:08:14 +01:00
tundra ethernet: tundra: free irq when alloc ring failed in tsi108_open() 2022-11-16 09:58:23 +01:00
via
wiznet
xilinx net: ll_temac: fix error checking of irq_of_parse_and_map() 2023-08-11 15:13:53 +02:00
xircom xirc2ps_cs: Fix use after free bug in xirc2ps_detach 2023-03-30 12:47:45 +02:00
xscale
Kconfig
Makefile
dnet.c net: ethernet: dnet: don't call dev_kfree_skb() under spin_lock_irqsave() 2022-12-31 13:14:19 +01:00
dnet.h
ec_bhf.c
ethoc.c ethernet: use of_get_ethdev_address() 2023-07-27 08:47:00 +02:00
fealnx.c
jme.c
jme.h
korina.c net: korina: handle clk prepare error in korina_probe() 2023-08-11 15:13:53 +02:00
lantiq_etop.c net: lantiq_etop: don't free skb when returning NETDEV_TX_BUSY 2022-11-03 23:59:16 +09:00
lantiq_xrx200.c ethernet: use of_get_ethdev_address() 2023-07-27 08:47:00 +02:00