Skip to contentSkip to conversation

can: af_can: can_rcv(): replace WARN_ONCE by pr_warn_once

PATCH In review Oliver Hartkopp 3 participants 4 messages Jan 22, 2018 – Jan 24, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 can: af_can: can_rcv(): replace WARN_ONCE by pr_warn_once

In Linux 4.12 commit 8e8cda6d737d356054c ("can: initial support for network namespaces") removed a namespace check which affected this patch:

upstream commit 8cb68751c115d176ec851ca56ecfbb411568c9e8

can: af_can: can_rcv(): replace WARN_ONCE by pr_warn_once

If an invalid CAN 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.

---
 net/can/af_can.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
net/can/af_can.c +5 -6
index 928f58064098..924ad0513af9 100644
@@ -722,13 +722,12 @@ static int can_rcv(struct sk_buff *skb, struct net_device *dev,
 	if (unlikely(!net_eq(dev_net(dev), &init_net)))
 		goto drop;
 
-	if (WARN_ONCE(dev->type != ARPHRD_CAN ||
-		      skb->len != CAN_MTU ||
-		      cfd->len > CAN_MAX_DLEN,
-		      "PF_CAN: dropped non conform CAN skbuf: "
-		      "dev type %d, len %d, datalen %d\n",
-		      dev->type, skb->len, cfd->len))
+	if (unlikely(dev->type != ARPHRD_CAN || skb->len != CAN_MTU ||
+		     cfd->len > CAN_MAX_DLEN)) {
+		pr_warn_once("PF_CAN: dropped non conform CAN skbuf: dev type %d, len %d, datalen %d\n",
+			     dev->type, skb->len, cfd->len);
 		goto drop;
+	}
 
 	can_receive(skb, dev);
 	return NET_RX_SUCCESS;
Signature · 1 line
2.15.1
#1 lore raw

PATCH 2/2 can: af_can: canfd_rcv(): replace WARN_ONCE by pr_warn_once

In Linux 4.12 commit 8e8cda6d737d356054c ("can: initial support for network namespaces") removed a namespace check which affected this patch:

can: af_can: canfd_rcv(): replace WARN_ONCE by pr_warn_once

upstream commit d4689846881d160a4d12a514e991a740bcb5d65a

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.

---
 net/can/af_can.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
net/can/af_can.c +5 -6
index 924ad0513af9..c866e761651a 100644
@@ -745,13 +745,12 @@ static int canfd_rcv(struct sk_buff *skb, struct net_device *dev,
 	if (unlikely(!net_eq(dev_net(dev), &init_net)))
 		goto drop;
 
-	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))
+	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);
 		goto drop;
+	}
 
 	can_receive(skb, dev);
 	return NET_RX_SUCCESS;
Signature · 1 line
2.15.1
maintainer
#2 lore raw

Re: [PATCH 2/2] [stable pre-4.12] can: af_can: canfd_rcv(): replace WARN_ONCE by pr_warn_once

Quoted 2 lines · Oliver Hartkopp

In Linux 4.12 commit 8e8cda6d737d356054c ("can: initial support for network namespaces") removed a namespace check which affected this patch:

Thanks for the two backports, now queued up.

greg k-h

#3 lore raw
In reply to Oliver Hartkopp
Quoted 14 lines · Oliver Hartkopp

In Linux 4.12 commit 8e8cda6d737d356054c ("can: initial support for network namespaces") removed a namespace check which affected this patch:

upstream commit 8cb68751c115d176ec851ca56ecfbb411568c9e8

can: af_can: can_rcv(): replace WARN_ONCE by pr_warn_once

If an invalid CAN 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.

Quoted 6 lines

nice!

thnx,
Marc

Signature · 4 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |