[Intel-wired-lan] [PATCH v1 3/4] fm10k: fix fm10k_add_ethtool_stats to zero memory

Jacob Keller jacob.e.keller at intel.com
Thu Apr 7 15:21:22 UTC 2016


The ethtool API does not guarantee zero'd memory, so we need to zero the
stats we skip instead of just skipping them.

Signed-off-by: Jacob Keller <jacob.e.keller at intel.com>
---

Notes:
    Testing-hints:
      Ensure that the queue stats don't show random memory values, but always zero
      if they are unused.
    
    Unfortunately, somehow Dave Miller pulled an incorrect version of the original
    for this patch, so this is a follow-on fixup which brings back the bug fix.

 drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
index b4870b8ad0bd..9c0d87503977 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
@@ -243,9 +243,10 @@ static void fm10k_add_ethtool_stats(u64 **data, void *pointer,
 	unsigned int i;
 	char *p;
 
-	/* simply skip forward if we were not given a valid pointer */
 	if (!pointer) {
-		*data += size;
+		/* memory is not zero allocated so we have to clear it */
+		for (i = 0; i < size; i++)
+			*((*data)++) = 0;
 		return;
 	}
 
-- 
2.8.1.102.ga49ec4a



More information about the Intel-wired-lan mailing list