From 16c94e5aee258b1d856e29493746db9afce8963a Mon Sep 17 00:00:00 2001 From: Ziyang Xuan Date: Thu, 20 Jan 2022 15:17:54 +0800 Subject: [PATCH] can: isotp: debug for reproducing isotp_rcv panic Signed-off-by: Ziyang Xuan --- net/can/isotp.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/net/can/isotp.c b/net/can/isotp.c index df6968b28bf4..8b12d63b4d59 100644 --- a/net/can/isotp.c +++ b/net/can/isotp.c @@ -119,8 +119,8 @@ enum { }; struct tpcon { - int idx; - int len; + unsigned int idx; + unsigned int len; u32 state; u8 bs; u8 sn; @@ -505,6 +505,7 @@ static int isotp_rcv_cf(struct sock *sk, struct canfd_frame *cf, int ae, struct isotp_sock *so = isotp_sk(sk); struct sk_buff *nskb; int i; + bool unexpection = false; if (so->rx.state != ISOTP_WAIT_DATA) return 0; @@ -562,11 +563,13 @@ static int isotp_rcv_cf(struct sock *sk, struct canfd_frame *cf, int ae, sk_error_report(sk); return 1; } - + if (so->rx.len == 0) + unexpection = true; nskb = alloc_skb(so->rx.len, gfp_any()); if (!nskb) return 1; - + if (unexpection) + printk("%s: before alloc_skb so->rc.len: 0, after alloc_skb so->rx.len: %u\n", __func__, so->rx.len); memcpy(skb_put(nskb, so->rx.len), so->rx.buf, so->rx.len); -- 2.25.1