wifi: ipw2x00: fix format-truncation warnings
authorKalle Valo <kvalo@kernel.org>
Thu, 12 Oct 2023 13:58:53 +0000 (16:58 +0300)
committerKalle Valo <kvalo@kernel.org>
Mon, 23 Oct 2023 17:24:39 +0000 (20:24 +0300)
On v6.6-rc4 with GCC 13.2 I see:

drivers/net/wireless/intel/ipw2x00/ipw2100.c:5905:63: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size 32 [-Wformat-truncation=]
drivers/net/wireless/intel/ipw2x00/ipw2100.c:5905:9: note: 'snprintf' output between 4 and 140 bytes into a destination of size 32
drivers/net/wireless/intel/ipw2x00/ipw2200.c:10392:63: warning: '%s' directive output may be truncated writing up to 63 bytes into a region of size 32 [-Wformat-truncation=]
drivers/net/wireless/intel/ipw2x00/ipw2200.c:10392:9: note: 'snprintf' output between 4 and 98 bytes into a destination of size 32

Fix this by copying only the firmware version and not providing any extra
information via ethtool. This is an ancient driver anyway and most likely
removed soon so it doesn't really matter.

Compile tested only.

Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20231012135854.3473332-2-kvalo@kernel.org
drivers/net/wireless/intel/ipw2x00/ipw2100.c
drivers/net/wireless/intel/ipw2x00/ipw2200.c

index 0812db8936f132b7de4f34b4e293284d5742e3b5..b6636002c7d220eeeb08b12f2bc23c2dd924455f 100644 (file)
@@ -317,8 +317,6 @@ static int ipw2100_get_firmware(struct ipw2100_priv *priv,
                                struct ipw2100_fw *fw);
 static int ipw2100_get_fwversion(struct ipw2100_priv *priv, char *buf,
                                 size_t max);
-static int ipw2100_get_ucodeversion(struct ipw2100_priv *priv, char *buf,
-                                   size_t max);
 static void ipw2100_release_firmware(struct ipw2100_priv *priv,
                                     struct ipw2100_fw *fw);
 static int ipw2100_ucode_download(struct ipw2100_priv *priv,
@@ -5894,17 +5892,14 @@ static void ipw_ethtool_get_drvinfo(struct net_device *dev,
                                    struct ethtool_drvinfo *info)
 {
        struct ipw2100_priv *priv = libipw_priv(dev);
-       char fw_ver[64], ucode_ver[64];
+       char fw_ver[64];
 
        strscpy(info->driver, DRV_NAME, sizeof(info->driver));
        strscpy(info->version, DRV_VERSION, sizeof(info->version));
 
        ipw2100_get_fwversion(priv, fw_ver, sizeof(fw_ver));
-       ipw2100_get_ucodeversion(priv, ucode_ver, sizeof(ucode_ver));
-
-       snprintf(info->fw_version, sizeof(info->fw_version), "%s:%d:%s",
-                fw_ver, priv->eeprom_version, ucode_ver);
 
+       strscpy(info->fw_version, fw_ver, sizeof(info->fw_version));
        strscpy(info->bus_info, pci_name(priv->pci_dev),
                sizeof(info->bus_info));
 }
@@ -8406,17 +8401,6 @@ static int ipw2100_get_fwversion(struct ipw2100_priv *priv, char *buf,
        return tmp;
 }
 
-static int ipw2100_get_ucodeversion(struct ipw2100_priv *priv, char *buf,
-                                   size_t max)
-{
-       u32 ver;
-       u32 len = sizeof(ver);
-       /* microcode version is a 32 bit integer */
-       if (ipw2100_get_ordinal(priv, IPW_ORD_UCODE_VERSION, &ver, &len))
-               return -EIO;
-       return snprintf(buf, max, "%08X", ver);
-}
-
 /*
  * On exit, the firmware will have been freed from the fw list
  */
index 820100cac4915055d8890cf88ab8feb103aa4d9b..902a772f46499d334fb4b552a10f5b27c1091686 100644 (file)
@@ -10378,7 +10378,6 @@ static void ipw_ethtool_get_drvinfo(struct net_device *dev,
 {
        struct ipw_priv *p = libipw_priv(dev);
        char vers[64];
-       char date[32];
        u32 len;
 
        strscpy(info->driver, DRV_NAME, sizeof(info->driver));
@@ -10386,11 +10385,8 @@ static void ipw_ethtool_get_drvinfo(struct net_device *dev,
 
        len = sizeof(vers);
        ipw_get_ordinal(p, IPW_ORD_STAT_FW_VERSION, vers, &len);
-       len = sizeof(date);
-       ipw_get_ordinal(p, IPW_ORD_STAT_FW_DATE, date, &len);
 
-       snprintf(info->fw_version, sizeof(info->fw_version), "%s (%s)",
-                vers, date);
+       strscpy(info->fw_version, vers, sizeof(info->fw_version));
        strscpy(info->bus_info, pci_name(p->pci_dev),
                sizeof(info->bus_info));
 }