diff options
-rw-r--r-- | net/can/af_can.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/net/can/af_can.c b/net/can/af_can.c index e733725b11d4..f9c027be78b2 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++; |
@@ -683,6 +687,10 @@ static int can_rcv(struct sk_buff *skb, struct net_device *dev, | |||
683 | } | 687 | } |
684 | 688 | ||
685 | return 0; | 689 | return 0; |
690 | |||
691 | drop: | ||
692 | kfree_skb(skb); | ||
693 | return 0; | ||
686 | } | 694 | } |
687 | 695 | ||
688 | /* | 696 | /* |