From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 687F5C47089 for ; Mon, 5 Dec 2022 14:26:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231586AbiLEO0Z (ORCPT ); Mon, 5 Dec 2022 09:26:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230090AbiLEO0X (ORCPT ); Mon, 5 Dec 2022 09:26:23 -0500 Received: from mail.netfilter.org (mail.netfilter.org [217.70.188.207]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BF0761E1; Mon, 5 Dec 2022 06:26:22 -0800 (PST) Date: Mon, 5 Dec 2022 15:26:16 +0100 From: Pablo Neira Ayuso To: Li Qiong Cc: Jozsef Kadlecsik , Florian Westphal , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org, kernel-janitors@vger.kernel.org, coreteam@netfilter.org, Yu Zhe Subject: Re: [PATCH] netfilter: initialize 'ret' variable Message-ID: References: <20221202070331.10865-1-liqiong@nfschina.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20221202070331.10865-1-liqiong@nfschina.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, Dec 02, 2022 at 03:03:31PM +0800, Li Qiong wrote: > The 'ret' should need to be initialized to 0, in case > return a uninitialized value. > > Signed-off-by: Li Qiong > --- > net/netfilter/nf_flow_table_ip.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/net/netfilter/nf_flow_table_ip.c b/net/netfilter/nf_flow_table_ip.c > index b350fe9d00b0..225ff865d609 100644 > --- a/net/netfilter/nf_flow_table_ip.c > +++ b/net/netfilter/nf_flow_table_ip.c > @@ -351,7 +351,7 @@ nf_flow_offload_ip_hook(void *priv, struct sk_buff *skb, > struct rtable *rt; > struct iphdr *iph; > __be32 nexthop; > - int ret; > + int ret = 0; > > if (skb->protocol != htons(ETH_P_IP) && > !nf_flow_skb_encap_protocol(skb, htons(ETH_P_IP), &offset)) > @@ -613,7 +613,7 @@ nf_flow_offload_ipv6_hook(void *priv, struct sk_buff *skb, > u32 hdrsize, offset = 0; > struct ipv6hdr *ip6h; > struct rt6_info *rt; > - int ret; > + int ret = 0; > > if (skb->protocol != htons(ETH_P_IPV6) && > !nf_flow_skb_encap_protocol(skb, htons(ETH_P_IPV6), &offset)) This can only happen with tuplehash->tuple.xmit_type: - FLOW_OFFLOAD_XMIT_UNSPEC - FLOW_OFFLOAD_XMIT_TC but this should not ever happen in that path. Instead, I'd suggest to add a 'default' case to the switch, set ret to NF_DROP and WARN_ON_ONCE(1).