Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6033755rwb; Mon, 5 Dec 2022 07:12:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf7dwbFfCe5m60+qYSQ70SsvdsZQYDkyvZeLmnSzXwP0MdxhbBkLW3ePBDzhXiXl3XwAAbY0 X-Received: by 2002:a17:903:555:b0:189:959a:84cc with SMTP id jo21-20020a170903055500b00189959a84ccmr34043792plb.41.1670253152713; Mon, 05 Dec 2022 07:12:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670253152; cv=none; d=google.com; s=arc-20160816; b=RvGMZGbpipyVh6KVrHsgPL886ZxMn12rHQ6DJv4rdmF5gNv+I9ZD4qmaDz57ne8ZGb OMZFY6S3FYcsZqjbGVz8OnBQ9KA50F9gbkIEgK6eRpGVvG4iKT6tFaymZTXsWiXpI1vJ 3WgmookZIDNd2nP5KimIafemGdXc1itIXXnbqaC1HtBDtu/y99PRI88mHu4Gz1hphyBf g/kUw9YWBtuPz/UG81mXHvzfYzNRcdX7lee8lT4TQ20g/VzG0Gqp0tpEEUzK7MzfRQAN oFxRqfypjpXEn1qM/ENl9fsRwche4QUAk/II9gd/FxvM8a9XF2V5iQ4yvukXTPkMzhXX webw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=lloBekUvKfhL5IK0QTnxP+RaqSIzEV2mIH1PgUcCTKw=; b=PVVjsj/YT1vqROQPfXB89h69ntWZVosnGi0PfLUon65Gurxlq4DhqguJ5FiTCcKs/S MlbgbCnD6QmJEd/IDL5OEkOQVgrUgaPH+HXGN4vxkXgTXX3TtE9/7tR2qNpoEJdCsEZJ V/AFwr9GHGgWJb+GC1WZIG5br9gpyGtEcyR7Lu/8Z0Kw/yX5K27LD82x7eghAvSEiMmY sDqiWn333ways2YCyskzEWLXlrBygW3wVSJjEanVpxKb9HPCDwVmhdvmaimP/03fwJGt d4aaVe0FybNKX6ZFFU9FJbxQuG2ZKiL6oQ6b5F0m8Tsj5c3TNTTo9h62iekKL5awiPYq pGUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u36-20020a634724000000b0043c3f90f7c8si14202156pga.655.2022.12.05.07.12.20; Mon, 05 Dec 2022 07:12:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231799AbiLEO01 (ORCPT + 82 others); Mon, 5 Dec 2022 09:26:27 -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> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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).