diff options
Diffstat (limited to 'net/can/af_can.c')
-rw-r--r-- | net/can/af_can.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/net/can/af_can.c b/net/can/af_can.c index e733725b11d4..ef1c43a2ed56 100644 --- a/net/can/af_can.c +++ b/net/can/af_can.c | |||
@@ -651,12 +651,16 @@ static int can_rcv(struct sk_buff *skb, struct net_device *dev, | |||
651 | struct can_frame *cf = (struct can_frame *)skb->data; | 651 | struct can_frame *cf = (struct can_frame *)skb->data; |
652 | int matches; | 652 | int matches; |
653 | 653 | ||
654 | if (dev->type != ARPHRD_CAN || !net_eq(dev_net(dev), &init_net)) { | 654 | if (!net_eq(dev_net(dev), &init_net)) |
655 | kfree_skb(skb); | 655 | goto drop; |
656 | return 0; | ||
657 | } | ||
658 | 656 | ||
659 | BUG_ON(skb->len != sizeof(struct can_frame) || cf->can_dlc > 8); | 657 | if (WARN_ONCE(dev->type != ARPHRD_CAN || |
658 | skb->len != sizeof(struct can_frame) || | ||
659 | cf->can_dlc > 8, | ||
660 | "PF_CAN: dropped non conform skbuf: " | ||
661 | "dev type %d, len %d, can_dlc %d\n", | ||
662 | dev->type, skb->len, cf->can_dlc)) | ||
663 | goto drop; | ||
660 | 664 | ||
661 | /* update statistics */ | 665 | /* update statistics */ |
662 | can_stats.rx_frames++; | 666 | can_stats.rx_frames++; |
@@ -682,7 +686,11 @@ static int can_rcv(struct sk_buff *skb, struct net_device *dev, | |||
682 | can_stats.matches_delta++; | 686 | can_stats.matches_delta++; |
683 | } | 687 | } |
684 | 688 | ||
685 | return 0; | 689 | return NET_RX_SUCCESS; |
690 | |||
691 | drop: | ||
692 | kfree_skb(skb); | ||
693 | return NET_RX_DROP; | ||
686 | } | 694 | } |
687 | 695 | ||
688 | /* | 696 | /* |