aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorOliver Hartkopp <oliver@hartkopp.net>2008-05-08 02:49:55 -0700
committerDavid S. Miller <davem@davemloft.net>2008-05-08 02:49:55 -0700
commitc2ab7ac225e29006b7117d6a9fe8f3be8d98b0c2 (patch)
tree6e327f59003db8e1de548623b08f4b8bb14c308f /net
parent33f9936b2b73dba6c8685994c441c4fd30b04814 (diff)
downloadkernel_samsung_smdk4412-c2ab7ac225e29006b7117d6a9fe8f3be8d98b0c2.tar.gz
kernel_samsung_smdk4412-c2ab7ac225e29006b7117d6a9fe8f3be8d98b0c2.tar.bz2
kernel_samsung_smdk4412-c2ab7ac225e29006b7117d6a9fe8f3be8d98b0c2.zip
can: Fix can_send() handling on dev_queue_xmit() failures
The tx packet counting and the local loopback of CAN frames should only happen in the case that the CAN frame has been enqueued to the netdevice tx queue successfully. Thanks to Andre Naujoks <nautsch@gmail.com> for reporting this issue. Signed-off-by: Oliver Hartkopp <oliver@hartkopp.net> Signed-off-by: Urs Thuermann <urs@isnogud.escape.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/can/af_can.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/net/can/af_can.c b/net/can/af_can.c
index 2759b76f731..7e8ca283645 100644
--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -208,6 +208,7 @@ static int can_create(struct net *net, struct socket *sock, int protocol)
*/
int can_send(struct sk_buff *skb, int loop)
{
+ struct sk_buff *newskb = NULL;
int err;
if (skb->dev->type != ARPHRD_CAN) {
@@ -244,8 +245,7 @@ int can_send(struct sk_buff *skb, int loop)
* If the interface is not capable to do loopback
* itself, we do it here.
*/
- struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC);
-
+ newskb = skb_clone(skb, GFP_ATOMIC);
if (!newskb) {
kfree_skb(skb);
return -ENOMEM;
@@ -254,7 +254,6 @@ int can_send(struct sk_buff *skb, int loop)
newskb->sk = skb->sk;
newskb->ip_summed = CHECKSUM_UNNECESSARY;
newskb->pkt_type = PACKET_BROADCAST;
- netif_rx(newskb);
}
} else {
/* indication for the CAN driver: no loopback required */
@@ -266,11 +265,20 @@ int can_send(struct sk_buff *skb, int loop)
if (err > 0)
err = net_xmit_errno(err);
+ if (err) {
+ if (newskb)
+ kfree_skb(newskb);
+ return err;
+ }
+
+ if (newskb)
+ netif_rx(newskb);
+
/* update statistics */
can_stats.tx_frames++;
can_stats.tx_frames_delta++;
- return err;
+ return 0;
}
EXPORT_SYMBOL(can_send);