wifi: iwlwifi: fw: increase fw_version string size
authorGregory Greenman <gregory.greenman@intel.com>
Thu, 12 Oct 2023 12:41:48 +0000 (15:41 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 23 Oct 2023 10:25:53 +0000 (12:25 +0200)
In reality 64 bytes are enough to hold fw version string,
but some compilers can complain (with W=1) that output may be
truncated when building this string with snprintf.
Increase the size to avoid this sort of warnings and state
explicitely that we want the size to be trancated to 32 bytes.

Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Tested-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20231012153950.f4465b4b4e2b.Idced2e8d63c492872edcde1a3ce2cdd6cc0f8eb7@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/dvm/main.c
drivers/net/wireless/intel/iwlwifi/fw/img.h
drivers/net/wireless/intel/iwlwifi/mvm/ops.c

index a873be109f439938315801d6e84720d371e70154..8774dd7b921effb43568d09a92c6f7ec47260d16 100644 (file)
@@ -1464,7 +1464,7 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans,
 
        snprintf(priv->hw->wiphy->fw_version,
                 sizeof(priv->hw->wiphy->fw_version),
-                "%s", fw->fw_version);
+                "%.31s", fw->fw_version);
 
        priv->new_scan_threshold_behaviour =
                !!(ucode_flags & IWL_UCODE_TLV_FLAGS_NEWSCAN);
index 8d0d58d618921cfe313fccd59a6d8ea94ba0f504..96bda80632f3d79cc2c852226a6a96d1ea0d3d94 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
 /*
- * Copyright (C) 2005-2014, 2018-2021 Intel Corporation
+ * Copyright (C) 2005-2014, 2018-2023 Intel Corporation
  * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
  * Copyright (C) 2016 Intel Deutschland GmbH
  */
@@ -198,7 +198,7 @@ struct iwl_dump_exclude {
 struct iwl_fw {
        u32 ucode_ver;
 
-       char fw_version[64];
+       char fw_version[128];
 
        /* ucode images */
        struct fw_img img[IWL_UCODE_TYPE_MAX];
index 465090f67aaf2908cf10135ac1e7dbbd2c661b72..4390adc31a298c0aa2bc441bf58de2762529f2c3 100644 (file)
@@ -1304,7 +1304,7 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg,
 
        snprintf(mvm->hw->wiphy->fw_version,
                 sizeof(mvm->hw->wiphy->fw_version),
-                "%s", fw->fw_version);
+                "%.31s", fw->fw_version);
 
        trans_cfg.fw_reset_handshake = fw_has_capa(&mvm->fw->ucode_capa,
                                                   IWL_UCODE_TLV_CAPA_FW_RESET_HANDSHAKE);