diff options
author | Oliver Hartkopp <oliver@hartkopp.net> | 2009-08-13 18:54:25 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-08-14 19:36:57 -0400 |
commit | 1758c0947605211ef953cc91d6bbdf847a21b822 (patch) | |
tree | 695e60450ec85f7e48b00949c29324c89eca7f20 /net | |
parent | 49d4b8ba97034469b941d00d5ca1e3b897394e35 (diff) |
can: Use WARN_ONCE() instead of BUG_ON() for sanity check in receive path
To ensure a proper handling of CAN frames transported in skbuffs some checks
need to be performed at receive time.
As stated by Michael Olbrich and Luotao Fu BUG_ON() might be to restrictive.
This is right as we can just drop the non conform skbuff and the Kernel can
continue working.
This patch replaces the BUG_ON() with a WARN_ONCE() so that the system remains
healthy but we made the problem visible (once).
Signed-off-by: Oliver Hartkopp <oliver@hartkopp.net>
Signed-off-by: Urs Thuermann <urs@isnogud.escape.de>
CC: Michael Olbrich <m.olbrich@pengutronix.de>
CC: Luotao Fu <l.fu@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-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 | /* |