Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 5a4ae5f

Browse files
Li RongQingdavem330
Li RongQing
authored andcommitted
vlan: unnecessary to check if vlan_pcpu_stats is NULL
if allocating memory for vlan_pcpu_stats failed, the device can not be operated Signed-off-by: Li RongQing <[email protected]> Cc: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e255787 commit 5a4ae5f

File tree

1 file changed

+28
-30
lines changed

1 file changed

+28
-30
lines changed

Diff for: net/8021q/vlan_dev.c

+28-30
Original file line numberDiff line numberDiff line change
@@ -706,38 +706,36 @@ static void vlan_ethtool_get_drvinfo(struct net_device *dev,
706706

707707
static struct rtnl_link_stats64 *vlan_dev_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
708708
{
709+
struct vlan_pcpu_stats *p;
710+
u32 rx_errors = 0, tx_dropped = 0;
711+
int i;
709712

710-
if (vlan_dev_priv(dev)->vlan_pcpu_stats) {
711-
struct vlan_pcpu_stats *p;
712-
u32 rx_errors = 0, tx_dropped = 0;
713-
int i;
714-
715-
for_each_possible_cpu(i) {
716-
u64 rxpackets, rxbytes, rxmulticast, txpackets, txbytes;
717-
unsigned int start;
718-
719-
p = per_cpu_ptr(vlan_dev_priv(dev)->vlan_pcpu_stats, i);
720-
do {
721-
start = u64_stats_fetch_begin_irq(&p->syncp);
722-
rxpackets = p->rx_packets;
723-
rxbytes = p->rx_bytes;
724-
rxmulticast = p->rx_multicast;
725-
txpackets = p->tx_packets;
726-
txbytes = p->tx_bytes;
727-
} while (u64_stats_fetch_retry_irq(&p->syncp, start));
728-
729-
stats->rx_packets += rxpackets;
730-
stats->rx_bytes += rxbytes;
731-
stats->multicast += rxmulticast;
732-
stats->tx_packets += txpackets;
733-
stats->tx_bytes += txbytes;
734-
/* rx_errors & tx_dropped are u32 */
735-
rx_errors += p->rx_errors;
736-
tx_dropped += p->tx_dropped;
737-
}
738-
stats->rx_errors = rx_errors;
739-
stats->tx_dropped = tx_dropped;
713+
for_each_possible_cpu(i) {
714+
u64 rxpackets, rxbytes, rxmulticast, txpackets, txbytes;
715+
unsigned int start;
716+
717+
p = per_cpu_ptr(vlan_dev_priv(dev)->vlan_pcpu_stats, i);
718+
do {
719+
start = u64_stats_fetch_begin_irq(&p->syncp);
720+
rxpackets = p->rx_packets;
721+
rxbytes = p->rx_bytes;
722+
rxmulticast = p->rx_multicast;
723+
txpackets = p->tx_packets;
724+
txbytes = p->tx_bytes;
725+
} while (u64_stats_fetch_retry_irq(&p->syncp, start));
726+
727+
stats->rx_packets += rxpackets;
728+
stats->rx_bytes += rxbytes;
729+
stats->multicast += rxmulticast;
730+
stats->tx_packets += txpackets;
731+
stats->tx_bytes += txbytes;
732+
/* rx_errors & tx_dropped are u32 */
733+
rx_errors += p->rx_errors;
734+
tx_dropped += p->tx_dropped;
740735
}
736+
stats->rx_errors = rx_errors;
737+
stats->tx_dropped = tx_dropped;
738+
741739
return stats;
742740
}
743741

0 commit comments

Comments
 (0)