diff options
author | Govindarajulu Varadarajan <_govind@gmx.com> | 2015-06-11 09:22:55 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-06-11 09:42:39 +0300 |
commit | 19b596bda1c5400808635fde0d521c1f89a6c1a3 (patch) | |
tree | 5484ba980423c60c8f684cc681d9c76883fe11ff /drivers/net/ethernet/cisco/enic/enic_main.c | |
parent | 6286e8285078ab02b215bba1d42a05ecfd864515 (diff) | |
download | linux-19b596bda1c5400808635fde0d521c1f89a6c1a3.tar.xz |
enic: check return value for stat dump
We do not check the return value of enic_dev_stats_dump(). If allocation
fails, we will hit NULL pointer reference.
Return only if memory allocation fails. For other failures, we return the
previously recorded values.
Signed-off-by: Govindarajulu Varadarajan <_govind@gmx.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/cisco/enic/enic_main.c')
-rw-r--r-- | drivers/net/ethernet/cisco/enic/enic_main.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c index 0e5a01dd7545..eadae1b412c6 100644 --- a/drivers/net/ethernet/cisco/enic/enic_main.c +++ b/drivers/net/ethernet/cisco/enic/enic_main.c @@ -615,8 +615,15 @@ static struct rtnl_link_stats64 *enic_get_stats(struct net_device *netdev, { struct enic *enic = netdev_priv(netdev); struct vnic_stats *stats; + int err; - enic_dev_stats_dump(enic, &stats); + err = enic_dev_stats_dump(enic, &stats); + /* return only when pci_zalloc_consistent fails in vnic_dev_stats_dump + * For other failures, like devcmd failure, we return previously + * recorded stats. + */ + if (err == -ENOMEM) + return net_stats; net_stats->tx_packets = stats->tx.tx_frames_ok; net_stats->tx_bytes = stats->tx.tx_bytes_ok; |