1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/drivers/net/ethernet/intel/igb
Kunwu Chan c56d055893 igb: Fix string truncation warnings in igb_set_fw_version
Commit 1978d3ead8 ("intel: fix string truncation warnings")
fixes '-Wformat-truncation=' warnings in igb_main.c by using kasprintf.

drivers/net/ethernet/intel/igb/igb_main.c:3092:53: warning:‘%d’ directive output may be truncated writing between 1 and 5 bytes into a region of size between 1 and 13 [-Wformat-truncation=]
 3092 |                                  "%d.%d, 0x%08x, %d.%d.%d",
      |                                                     ^~
drivers/net/ethernet/intel/igb/igb_main.c:3092:34: note:directive argument in the range [0, 65535]
 3092 |                                  "%d.%d, 0x%08x, %d.%d.%d",
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/intel/igb/igb_main.c:3092:34: note:directive argument in the range [0, 65535]
drivers/net/ethernet/intel/igb/igb_main.c:3090:25: note:‘snprintf’ output between 23 and 43 bytes into a destination of size 32

kasprintf() returns a pointer to dynamically allocated memory
which can be NULL upon failure.

Fix this warning by using a larger space for adapter->fw_version,
and then fall back and continue to use snprintf.

Fixes: 1978d3ead8 ("intel: fix string truncation warnings")
Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
Cc: Kunwu Chan <kunwu.chan@hotmail.com>
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
2024-02-14 09:43:09 -08:00
..
e1000_82575.c intel: legacy: field get conversion 2023-12-18 11:20:43 -08:00
e1000_82575.h igb: Add UDP segmentation offload support 2019-10-29 21:05:33 -07:00
e1000_defines.h igb: Remove duplicate defines 2022-06-09 10:05:31 -07:00
e1000_hw.h igb: Fix duplicate include guard 2021-03-19 08:47:46 -07:00
e1000_i210.c intel: legacy: field get conversion 2023-12-18 11:20:43 -08:00
e1000_i210.h net: intel: Cleanup the copyright/license headers 2018-04-27 14:00:04 -04:00
e1000_mac.c intel: legacy: field get conversion 2023-12-18 11:20:43 -08:00
e1000_mac.h net: intel: Cleanup the copyright/license headers 2018-04-27 14:00:04 -04:00
e1000_mbx.c intel: clean up mismatched header comments 2021-03-23 11:34:02 -07:00
e1000_mbx.h net: intel: Cleanup the copyright/license headers 2018-04-27 14:00:04 -04:00
e1000_nvm.c intel: legacy: field get conversion 2023-12-18 11:20:43 -08:00
e1000_nvm.h net: intel: Cleanup the copyright/license headers 2018-04-27 14:00:04 -04:00
e1000_phy.c intel: legacy: field get conversion 2023-12-18 11:20:43 -08:00
e1000_phy.h net: intel: Cleanup the copyright/license headers 2018-04-27 14:00:04 -04:00
e1000_regs.h igb: Remove duplicate defines 2022-06-09 10:05:31 -07:00
igb.h igb: Fix string truncation warnings in igb_set_fw_version 2024-02-14 09:43:09 -08:00
igb_ethtool.c intel: legacy: field get conversion 2023-12-18 11:20:43 -08:00
igb_hwmon.c igb: convert to use i2c_new_client_device() 2020-03-26 19:31:21 -07:00
igb_main.c igb: Fix string truncation warnings in igb_set_fw_version 2024-02-14 09:43:09 -08:00
igb_ptp.c igb: Avoid starting unnecessary workqueues 2023-08-22 17:24:28 -07:00
Makefile net: intel: Cleanup the copyright/license headers 2018-04-27 14:00:04 -04:00