aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/qlogic/qlcnic
diff options
context:
space:
mode:
authorManish Chopra <manish.chopra@qlogic.com>2014-09-22 05:51:51 -0400
committerDavid S. Miller <davem@davemloft.net>2014-09-26 15:11:31 -0400
commitc023030198b2b0fb87f5d9bcb388c41bfaf3c3c0 (patch)
treef5c7c78025b56bbb86eec486507c18746e8b1389 /drivers/net/ethernet/qlogic/qlcnic
parent4324414f8ccae4997dd1e91646683679a4436959 (diff)
qlcnic: Fix memory corruption while reading stats using ethtool.
o Driver is doing memset with zero for total number of stats bytes when it has already filled some data in the stats buffer, which can overwrite memory area beyond the length of stats buffer. o Fix this by initializing stats buffer with zero before filling any data in it. Signed-off-by: Manish Chopra <manish.chopra@qlogic.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/qlogic/qlcnic')
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c
index 141f116eb868..2d77b7694d16 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c
@@ -1333,12 +1333,11 @@ static void qlcnic_get_ethtool_stats(struct net_device *dev,
1333 struct qlcnic_host_tx_ring *tx_ring; 1333 struct qlcnic_host_tx_ring *tx_ring;
1334 struct qlcnic_esw_statistics port_stats; 1334 struct qlcnic_esw_statistics port_stats;
1335 struct qlcnic_mac_statistics mac_stats; 1335 struct qlcnic_mac_statistics mac_stats;
1336 int index, ret, length, size, tx_size, ring; 1336 int index, ret, length, size, ring;
1337 char *p; 1337 char *p;
1338 1338
1339 tx_size = adapter->drv_tx_rings * QLCNIC_TX_STATS_LEN; 1339 memset(data, 0, stats->n_stats * sizeof(u64));
1340 1340
1341 memset(data, 0, tx_size * sizeof(u64));
1342 for (ring = 0, index = 0; ring < adapter->drv_tx_rings; ring++) { 1341 for (ring = 0, index = 0; ring < adapter->drv_tx_rings; ring++) {
1343 if (test_bit(__QLCNIC_DEV_UP, &adapter->state)) { 1342 if (test_bit(__QLCNIC_DEV_UP, &adapter->state)) {
1344 tx_ring = &adapter->tx_ring[ring]; 1343 tx_ring = &adapter->tx_ring[ring];
@@ -1347,7 +1346,6 @@ static void qlcnic_get_ethtool_stats(struct net_device *dev,
1347 } 1346 }
1348 } 1347 }
1349 1348
1350 memset(data, 0, stats->n_stats * sizeof(u64));
1351 length = QLCNIC_STATS_LEN; 1349 length = QLCNIC_STATS_LEN;
1352 for (index = 0; index < length; index++) { 1350 for (index = 0; index < length; index++) {
1353 p = (char *)adapter + qlcnic_gstrings_stats[index].stat_offset; 1351 p = (char *)adapter + qlcnic_gstrings_stats[index].stat_offset;