Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1871420rwb; Fri, 2 Dec 2022 02:14:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf7nSOvy5yhwAVJ4+XNmnL9EpYMO+6BfGKNFVgXzt7ECrUx6EvIuP2mQVd52m/nQbyd12O8D X-Received: by 2002:aa7:d7cc:0:b0:45b:4a4b:478c with SMTP id e12-20020aa7d7cc000000b0045b4a4b478cmr45002075eds.317.1669976084365; Fri, 02 Dec 2022 02:14:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669976084; cv=none; d=google.com; s=arc-20160816; b=I0qD3+jGd+661PAuzRXCnh0OPKH8RCoI/Q8cqH2ExVQ+W2Qf62t8JRtkkIudD672zs OcIZL99dEJ2jjVeJFnG8x/gOK/ZjwT5EC2YrE7FFYLS4D10ucKeVOjlA9g0BVrPgDUv2 7s6x8JjzPa/Z3gX0mT9xMUP9Y9Psjfg6EtH23TvKe6GG8wKgnXwdIgzLG0gNsAy2N1jb 42mty/VmQaQwsTb0PGdRVN8/XMUbj/EzwIvdtODa16q6corahMwMb0kL2d7/AYkDM98X xi5PAPtQJ8Pben5bBnfYEloUFWc5VG9UICbw5pjkk/aLiw+fTWSVb7cBqUbIh2G51qOz PS5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organisation:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=qhMcS057+cgSJLy7v8v4WrvZnLortXTRJZOxP5np5HQ=; b=smwwoyCPNd9eeTdMbJ6tdYd5a5d9b2zd56KMEeH6TXaBFCX+A7487pq3g8zAVD2ysT dORMuiqmZO+HQnmNrfNN7gqjqz9bgj9MLRCNExkEsYShhCjx7gCZUXQsbCogcEde9cNs VdZHPfGj7XFbT6BXQzHPyYm1m1NJ3Izxg0dyZtMSB/vEjqwJjtsgTJ+eM4j4US3D31S8 UK/yT7dr+G9HiIqxBJQrSlVUMryAc/pcN9S1bhazPzKFda4M1IEIHTOFf8rPyVw3zhIv u6z8Xp0z2O9OL0AXECWLZWsXrxo1la4K4I5fhuMiOTakxAYSX3+BANREzWb47Bq/VxVr gwgA== 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 o9-20020a170906974900b00791994dfb9esi6541211ejy.491.2022.12.02.02.14.24; Fri, 02 Dec 2022 02:14:44 -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 S233189AbiLBKCm (ORCPT + 83 others); Fri, 2 Dec 2022 05:02:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233171AbiLBKCk (ORCPT ); Fri, 2 Dec 2022 05:02:40 -0500 Received: from zeeaster.vergenet.net (zeeaster.vergenet.net [206.189.110.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 881A310B8; Fri, 2 Dec 2022 02:02:36 -0800 (PST) Received: from momiji.horms.nl (86-93-216-223.fixed.kpn.net [86.93.216.223]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by zeeaster.vergenet.net (Postfix) with ESMTPSA id 7F991200A3; Fri, 2 Dec 2022 10:02:04 +0000 (UTC) Received: by momiji.horms.nl (Postfix, from userid 7100) id 3436E9401C8; Fri, 2 Dec 2022 11:02:04 +0100 (CET) Date: Fri, 2 Dec 2022 11:02:04 +0100 From: Simon Horman To: Li Qiong Cc: Julian Anastasov , Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, lvs-devel@vger.kernel.org, netfilter-devel@vger.kernel.org, kernel-janitors@vger.kernel.org, coreteam@netfilter.org, Yu Zhe Subject: Re: [PATCH] ipvs: initialize 'ret' variable in do_ip_vs_set_ctl() Message-ID: References: <20221202032511.1435-1-liqiong@nfschina.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221202032511.1435-1-liqiong@nfschina.com> Organisation: Horms Solutions BV X-Virus-Scanned: clamav-milter 0.103.7 at zeeaster X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,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 11:25:11AM +0800, Li Qiong wrote: > The 'ret' should need to be initialized to 0, in case > return a uninitialized value because no default process > for "switch (cmd)". > > Signed-off-by: Li Qiong Thanks, I agree there seems to be a problem here. But perhaps it's nicer to solve it by adding a default case to the switch statement? Also, if we update the declaration of ret, perhaps we could also move it to the bottom of the declaration of local variables, to move more towards reverse xmas tree order. But to be honest, I don't feel strongly about either of these issues. So if someone wants to take this patch as-is then feel free to add. Reviewed-by: Simon Horman > --- > net/netfilter/ipvs/ip_vs_ctl.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c > index 988222fff9f0..4b20db86077c 100644 > --- a/net/netfilter/ipvs/ip_vs_ctl.c > +++ b/net/netfilter/ipvs/ip_vs_ctl.c > @@ -2456,7 +2456,7 @@ static int > do_ip_vs_set_ctl(struct sock *sk, int cmd, sockptr_t ptr, unsigned int len) > { > struct net *net = sock_net(sk); > - int ret; > + int ret = 0; > unsigned char arg[MAX_SET_ARGLEN]; > struct ip_vs_service_user *usvc_compat; > struct ip_vs_service_user_kern usvc; > -- > 2.11.0 >