Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bogendoerfer <tbogendoerfer@suse.de>2018-07-19 12:18:31 +0200
committerThomas Bogendoerfer <tbogendoerfer@suse.de>2018-07-19 12:22:03 +0200
commit3cb6584af611c43d4ecad4d5affce8fd368e7cdb (patch)
tree757f1a84b303c30457833a59085a91211b03453b
parent5f3d5badec47332a83e56599c55f205449e82bcc (diff)
fm10k: use macro to avoid passing the array and size separately
(bsc#1101813 FATE#325148).
-rw-r--r--patches.drivers/fm10k-use-macro-to-avoid-passing-the-array-and-size-.patch138
-rw-r--r--series.conf1
2 files changed, 139 insertions, 0 deletions
diff --git a/patches.drivers/fm10k-use-macro-to-avoid-passing-the-array-and-size-.patch b/patches.drivers/fm10k-use-macro-to-avoid-passing-the-array-and-size-.patch
new file mode 100644
index 0000000000..6b3f3dd03c
--- /dev/null
+++ b/patches.drivers/fm10k-use-macro-to-avoid-passing-the-array-and-size-.patch
@@ -0,0 +1,138 @@
+From: Jacob Keller <jacob.e.keller@intel.com>
+Date: Thu, 12 Apr 2018 11:15:57 -0700
+Subject: fm10k: use macro to avoid passing the array and size separately
+Patch-mainline: v4.18-rc1
+Git-commit: 36592d6ce8d38590894fb34329b0786386ee75bc
+References: bsc#1101813 FATE#325148
+
+Avoid potential bugs with fm10k_add_stat_strings and
+fm10k_add_ethtool_stats by using a macro to calculate the ARRAY_SIZE
+when passing. This helps ensure that the size is always correct.
+
+Note that it assumes we only pass static const fm10k_stat arrays, and
+that evaluation of the argument won't have side effects.
+
+Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
+Tested-by: Krishneil Singh <krishneil.k.singh@intel.com>
+Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
+Acked-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
+---
+ drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c | 48 ++++++++++-------------
+ 1 file changed, 21 insertions(+), 27 deletions(-)
+
+--- a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
++++ b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
+@@ -152,8 +152,8 @@ enum {
+ static const char fm10k_prv_flags[FM10K_PRV_FLAG_LEN][ETH_GSTRING_LEN] = {
+ };
+
+-static void fm10k_add_stat_strings(u8 **p, const struct fm10k_stats stats[],
+- const unsigned int size, ...)
++static void __fm10k_add_stat_strings(u8 **p, const struct fm10k_stats stats[],
++ const unsigned int size, ...)
+ {
+ unsigned int i;
+
+@@ -167,31 +167,28 @@ static void fm10k_add_stat_strings(u8 **
+ }
+ }
+
++#define fm10k_add_stat_strings(p, stats, ...) \
++ __fm10k_add_stat_strings(p, stats, ARRAY_SIZE(stats), ## __VA_ARGS__)
++
+ static void fm10k_get_stat_strings(struct net_device *dev, u8 *data)
+ {
+ struct fm10k_intfc *interface = netdev_priv(dev);
+ unsigned int i;
+
+- fm10k_add_stat_strings(&data, fm10k_gstrings_net_stats,
+- FM10K_NETDEV_STATS_LEN);
++ fm10k_add_stat_strings(&data, fm10k_gstrings_net_stats);
+
+- fm10k_add_stat_strings(&data, fm10k_gstrings_global_stats,
+- FM10K_GLOBAL_STATS_LEN);
++ fm10k_add_stat_strings(&data, fm10k_gstrings_global_stats);
+
+- fm10k_add_stat_strings(&data, fm10k_gstrings_mbx_stats,
+- FM10K_MBX_STATS_LEN);
++ fm10k_add_stat_strings(&data, fm10k_gstrings_mbx_stats);
+
+ if (interface->hw.mac.type != fm10k_mac_vf)
+- fm10k_add_stat_strings(&data, fm10k_gstrings_pf_stats,
+- FM10K_PF_STATS_LEN);
++ fm10k_add_stat_strings(&data, fm10k_gstrings_pf_stats);
+
+ for (i = 0; i < interface->hw.mac.max_queues; i++) {
+ fm10k_add_stat_strings(&data, fm10k_gstrings_queue_stats,
+- FM10K_QUEUE_STATS_LEN,
+ "tx", i);
+
+ fm10k_add_stat_strings(&data, fm10k_gstrings_queue_stats,
+- FM10K_QUEUE_STATS_LEN,
+ "rx", i);
+ }
+ }
+@@ -237,9 +234,9 @@ static int fm10k_get_sset_count(struct n
+ }
+ }
+
+-static void fm10k_add_ethtool_stats(u64 **data, void *pointer,
+- const struct fm10k_stats stats[],
+- const unsigned int size)
++static void __fm10k_add_ethtool_stats(u64 **data, void *pointer,
++ const struct fm10k_stats stats[],
++ const unsigned int size)
+ {
+ unsigned int i;
+ char *p;
+@@ -273,6 +270,9 @@ static void fm10k_add_ethtool_stats(u64
+ }
+ }
+
++#define fm10k_add_ethtool_stats(data, pointer, stats) \
++ __fm10k_add_ethtool_stats(data, pointer, stats, ARRAY_SIZE(stats))
++
+ static void fm10k_get_ethtool_stats(struct net_device *netdev,
+ struct ethtool_stats __always_unused *stats,
+ u64 *data)
+@@ -283,20 +283,16 @@ static void fm10k_get_ethtool_stats(stru
+
+ fm10k_update_stats(interface);
+
+- fm10k_add_ethtool_stats(&data, net_stats, fm10k_gstrings_net_stats,
+- FM10K_NETDEV_STATS_LEN);
++ fm10k_add_ethtool_stats(&data, net_stats, fm10k_gstrings_net_stats);
+
+- fm10k_add_ethtool_stats(&data, interface, fm10k_gstrings_global_stats,
+- FM10K_GLOBAL_STATS_LEN);
++ fm10k_add_ethtool_stats(&data, interface, fm10k_gstrings_global_stats);
+
+ fm10k_add_ethtool_stats(&data, &interface->hw.mbx,
+- fm10k_gstrings_mbx_stats,
+- FM10K_MBX_STATS_LEN);
++ fm10k_gstrings_mbx_stats);
+
+ if (interface->hw.mac.type != fm10k_mac_vf) {
+ fm10k_add_ethtool_stats(&data, interface,
+- fm10k_gstrings_pf_stats,
+- FM10K_PF_STATS_LEN);
++ fm10k_gstrings_pf_stats);
+ }
+
+ for (i = 0; i < interface->hw.mac.max_queues; i++) {
+@@ -304,13 +300,11 @@ static void fm10k_get_ethtool_stats(stru
+
+ ring = interface->tx_ring[i];
+ fm10k_add_ethtool_stats(&data, ring,
+- fm10k_gstrings_queue_stats,
+- FM10K_QUEUE_STATS_LEN);
++ fm10k_gstrings_queue_stats);
+
+ ring = interface->rx_ring[i];
+ fm10k_add_ethtool_stats(&data, ring,
+- fm10k_gstrings_queue_stats,
+- FM10K_QUEUE_STATS_LEN);
++ fm10k_gstrings_queue_stats);
+ }
+ }
+
diff --git a/series.conf b/series.conf
index 63f8a794e7..281c658c50 100644
--- a/series.conf
+++ b/series.conf
@@ -13926,6 +13926,7 @@
patches.drivers/fm10k-setup-VLANs-for-l2-accelerated-macvlan-interfa.patch
patches.drivers/fm10k-reduce-duplicate-fm10k_stat-macro-code.patch
patches.drivers/fm10k-use-variadic-arguments-to-fm10k_add_stat_strin.patch
+ patches.drivers/fm10k-use-macro-to-avoid-passing-the-array-and-size-.patch
patches.drivers/qed-Fix-possibility-of-list-corruption-during-rmmod-.patch
patches.drivers/qed-Fix-LL2-race-during-connection-terminate.patch
patches.drivers/mwifiex-pcie-tighten-a-check-in-mwifiex_pcie_process