From 05e37190ba07f6c601349725f3634909f88b3044 Mon Sep 17 00:00:00 2001 From: Sabrina Dubroca Date: Thu, 1 Oct 2026 09:57:26 +0200 Subject: [PATCH] net: strparser: remove strp->sk NULL checks strp_init makes sure strp->sk != NULL. Signed-off-by: Sabrina Dubroca Link: https://patch.msgid.link/a823a8decf85b3586e50adf8c6d768f59538140a.1790702233.git.sd@queasysnail.net Signed-off-by: Jakub Kicinski --- net/strparser/strparser.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/net/strparser/strparser.c b/net/strparser/strparser.c index b5319ed56857..6cdbd12f41e0 100644 --- a/net/strparser/strparser.c +++ b/net/strparser/strparser.c @@ -36,6 +36,8 @@ static inline struct _strp_msg *_strp_msg(struct sk_buff *skb) /* Lower lock held */ static void strp_abort_strp(struct strparser *strp, int err) { + struct sock *sk = strp->sk; + /* Unrecoverable error in receive */ cancel_delayed_work(&strp->msg_timer_work); @@ -53,13 +55,9 @@ static void strp_abort_strp(struct strparser *strp, int err) strp->skb_nextp = NULL; strp->need_bytes = 0; - if (strp->sk) { - struct sock *sk = strp->sk; - - /* Report an error on the lower socket */ - sk->sk_err = -err; - sk_error_report(sk); - } + /* Report an error on the lower socket */ + sk->sk_err = -err; + sk_error_report(sk); } static void strp_start_timer(struct strparser *strp, long timeo) @@ -80,17 +78,9 @@ static void strp_parser_err(struct strparser *strp, int err, static inline int strp_peek_len(struct strparser *strp) { - if (strp->sk) { - struct socket *sock = strp->sk->sk_socket; + struct socket *sock = strp->sk->sk_socket; - return sock->ops->peek_len(sock); - } - - /* If we don't have an associated socket there's nothing to peek. - * Return int max to avoid stopping the strparser. - */ - - return INT_MAX; + return sock->ops->peek_len(sock); } /* Lower socket lock held */