diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2013-09-06 22:27:11 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-09-11 16:03:12 -0400 |
commit | de9e8f3f4086b1e6ba302487074fb707f1a95fc7 (patch) | |
tree | 5466e1d77851f0dcca945c7c9dc3645a681d22fd /drivers/net/macvlan.c | |
parent | 97f3f6fc23e516012b614c263847120caaab7020 (diff) |
macvlan: Move skb_clone check closer to call
Currently macvlan calls skb_clone in macvlan_broadcast but checks
for a NULL return in macvlan_broadcast_one instead. This is
needlessly confusing and may lead to bugs introduced later.
This patch moves the error check to where the skb_clone call is.
The only other caller of macvlan_broadcast_one never passes in a
NULL value so it doesn't need the check either.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Thanks,
Reviewed-by: Simon Horman <horms@verge.net.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/macvlan.c')
-rw-r--r-- | drivers/net/macvlan.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 64dfaa303dcc..9bf46bd19b87 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c | |||
@@ -118,8 +118,6 @@ static int macvlan_broadcast_one(struct sk_buff *skb, | |||
118 | const struct ethhdr *eth, bool local) | 118 | const struct ethhdr *eth, bool local) |
119 | { | 119 | { |
120 | struct net_device *dev = vlan->dev; | 120 | struct net_device *dev = vlan->dev; |
121 | if (!skb) | ||
122 | return NET_RX_DROP; | ||
123 | 121 | ||
124 | if (local) | 122 | if (local) |
125 | return vlan->forward(dev, skb); | 123 | return vlan->forward(dev, skb); |
@@ -171,9 +169,13 @@ static void macvlan_broadcast(struct sk_buff *skb, | |||
171 | hash = mc_hash(vlan, eth->h_dest); | 169 | hash = mc_hash(vlan, eth->h_dest); |
172 | if (!test_bit(hash, vlan->mc_filter)) | 170 | if (!test_bit(hash, vlan->mc_filter)) |
173 | continue; | 171 | continue; |
172 | |||
173 | err = NET_RX_DROP; | ||
174 | nskb = skb_clone(skb, GFP_ATOMIC); | 174 | nskb = skb_clone(skb, GFP_ATOMIC); |
175 | err = macvlan_broadcast_one(nskb, vlan, eth, | 175 | if (likely(nskb)) |
176 | mode == MACVLAN_MODE_BRIDGE); | 176 | err = macvlan_broadcast_one( |
177 | nskb, vlan, eth, | ||
178 | mode == MACVLAN_MODE_BRIDGE); | ||
177 | macvlan_count_rx(vlan, skb->len + ETH_HLEN, | 179 | macvlan_count_rx(vlan, skb->len + ETH_HLEN, |
178 | err == NET_RX_SUCCESS, 1); | 180 | err == NET_RX_SUCCESS, 1); |
179 | } | 181 | } |