Skip to content

Commit

Permalink
can: af_can: canfd_rcv(): replace WARN_ONCE by pr_warn_once
Browse files Browse the repository at this point in the history
If an invalid CANFD frame is received, from a driver or from a tun
interface, a Kernel warning is generated.

This patch replaces the WARN_ONCE by a simple pr_warn_once, so that a
kernel, bootet with panic_on_warn, does not panic. A printk seems to be
more appropriate here.

Reported-by: [email protected]
Suggested-by: Dmitry Vyukov <[email protected]>
Acked-by: Oliver Hartkopp <[email protected]>
Cc: linux-stable <[email protected]>
Signed-off-by: Marc Kleine-Budde <[email protected]>
  • Loading branch information
marckleinebudde committed Jan 18, 2018
1 parent 8cb6875 commit d468984
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions net/can/af_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -738,20 +738,16 @@ static int canfd_rcv(struct sk_buff *skb, struct net_device *dev,
{
struct canfd_frame *cfd = (struct canfd_frame *)skb->data;

if (WARN_ONCE(dev->type != ARPHRD_CAN ||
skb->len != CANFD_MTU ||
cfd->len > CANFD_MAX_DLEN,
"PF_CAN: dropped non conform CAN FD skbuf: "
"dev type %d, len %d, datalen %d\n",
dev->type, skb->len, cfd->len))
goto drop;
if (unlikely(dev->type != ARPHRD_CAN || skb->len != CANFD_MTU ||
cfd->len > CANFD_MAX_DLEN)) {
pr_warn_once("PF_CAN: dropped non conform CAN FD skbuf: dev type %d, len %d, datalen %d\n",
dev->type, skb->len, cfd->len);
kfree_skb(skb);
return NET_RX_DROP;
}

can_receive(skb, dev);
return NET_RX_SUCCESS;

drop:
kfree_skb(skb);
return NET_RX_DROP;
}

/*
Expand Down

0 comments on commit d468984

Please sign in to comment.