enic: check return value for stat dump
[cascardo/linux.git] / drivers / net / ethernet / cisco / enic / enic_main.c
index a5179bf..eadae1b 100644 (file)
@@ -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;
@@ -893,7 +900,7 @@ static int enic_set_vf_port(struct net_device *netdev, int vf,
                } else {
                        memset(pp, 0, sizeof(*pp));
                        if (vf == PORT_SELF_VF)
-                               memset(netdev->dev_addr, 0, ETH_ALEN);
+                               eth_zero_addr(netdev->dev_addr);
                }
        } else {
                /* Set flag to indicate that the port assoc/disassoc
@@ -903,14 +910,14 @@ static int enic_set_vf_port(struct net_device *netdev, int vf,
 
                /* If DISASSOCIATE, clean up all assigned/saved macaddresses */
                if (pp->request == PORT_REQUEST_DISASSOCIATE) {
-                       memset(pp->mac_addr, 0, ETH_ALEN);
+                       eth_zero_addr(pp->mac_addr);
                        if (vf == PORT_SELF_VF)
-                               memset(netdev->dev_addr, 0, ETH_ALEN);
+                               eth_zero_addr(netdev->dev_addr);
                }
        }
 
        if (vf == PORT_SELF_VF)
-               memset(pp->vf_mac, 0, ETH_ALEN);
+               eth_zero_addr(pp->vf_mac);
 
        return err;
 }
@@ -1407,6 +1414,7 @@ static int enic_poll_msix_rq(struct napi_struct *napi, int budget)
                 */
                enic_calc_int_moderation(enic, &enic->rq[rq]);
 
+       enic_poll_unlock_napi(&enic->rq[rq]);
        if (work_done < work_to_do) {
 
                /* Some work done, but not enough to stay in polling,
@@ -1418,7 +1426,6 @@ static int enic_poll_msix_rq(struct napi_struct *napi, int budget)
                        enic_set_int_moderation(enic, &enic->rq[rq]);
                vnic_intr_unmask(&enic->intr[intr]);
        }
-       enic_poll_unlock_napi(&enic->rq[rq]);
 
        return work_done;
 }