Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1250241imw; Tue, 5 Jul 2022 06:26:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uL28Kdn9FI1fYhatbuOaNE3N2dak262JdmdP3Ck2oqvdDwYqY/J0JbDCF7SKuwmpxuDiT6 X-Received: by 2002:a05:6a00:a0c:b0:528:5233:f119 with SMTP id p12-20020a056a000a0c00b005285233f119mr17047091pfh.69.1657027564851; Tue, 05 Jul 2022 06:26:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657027564; cv=none; d=google.com; s=arc-20160816; b=zKbyJDWLo/dcoRk/WYasWTCDB6hRl41ecqcVPbqBF3ZCWHRygIlxj+aAry9QsYGGz5 GfIlKWSi/xwujdsWaBQAketicLTYhPNr+hN3Vo6vdjf8vn0BC+EhNHN6eVahFyl53hmB RGJqsbaA6tmcFiwhnxYLuPAysozb1cTNCHALLYIG1Yx1jEIZY3ug+8tRA9YaIUshfkIj okkJZFb2t9vTWsnRdYdrbQY8V5YXiFvnuOIdzWl31JfVDX88WjDXRCAcJRZxTV6TBg6d RhhJSw7HLaUKdz+imuT4YYWMQD16FIMKyGsd0kzIHwPzsmzheBLE4RwHToATeeA/Vnx7 HKqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CBMfRsApdLsgcG8aZ58YaH3Q2UuRlZ8XZbHg5+7hJG8=; b=ZdbNVs3j5t+ZcXcNTv7ns70rsNgJXSVKLkHAQZzjvn0gtg7cpoCvcbyqunTqSzjxCy JPJIHRWbfHaCLTvOD3fTAoiJcnXPRRDysvIHFyNpPahjRtWN3JrfSsfz4IQuiChQpB8M pQJ/ibMomyW7yOK2vToFxv7AICqsK8l3TRzXdSgW88lrI853UhBJ8212h86kuxjx+Vlb ND7tfn2xUSwmp3s4yi6jthXivFLX7nmRbCZ+mBv3xikj6ouWzX/GFIcUhui1/FFZKCLJ 4P0ct96dTMrSEUmi/jyzIfBNBXebhCxrIGLFAP+J53yA23mVGUomRT9TIBZPbI68zp57 3fJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hX181gDf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h7-20020a631207000000b0040cf947c74asi25100755pgl.280.2022.07.05.06.25.52; Tue, 05 Jul 2022 06:26:04 -0700 (PDT) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hX181gDf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234021AbiGEMFp (ORCPT + 99 others); Tue, 5 Jul 2022 08:05:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233546AbiGEMDW (ORCPT ); Tue, 5 Jul 2022 08:03:22 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E3EC2F0; Tue, 5 Jul 2022 05:03:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 008D2B817C7; Tue, 5 Jul 2022 12:03:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 500B4C341C7; Tue, 5 Jul 2022 12:03:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657022598; bh=64BPAfPk2SYeOMp4omlxmEEgu7WOkOHrFW5p+rdmDt0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hX181gDfVKTTBZUCgPy4r47aWYmaGA5USzvVxgmq3P7LS1B+kNcGWAJ9s59Rnpobn z6KoWFlMj+VMbHdNQtb5zSdhUwKwrUla3WQtXDWukfJp1F+alTr14GJ+lDvKz3LIJc X/TeVHDzRwvzAMkqVTv1fsspJ4zNVa0coKJBZfAM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, katrinzhou , Eric Dumazet , David Ahern , Jakub Kicinski Subject: [PATCH 4.19 26/33] ipv6/sit: fix ipip6_tunnel_get_prl return value Date: Tue, 5 Jul 2022 13:58:18 +0200 Message-Id: <20220705115607.479535856@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220705115606.709817198@linuxfoundation.org> References: <20220705115606.709817198@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: katrinzhou commit adabdd8f6acabc0c3fdbba2e7f5a2edd9c5ef22d upstream. When kcalloc fails, ipip6_tunnel_get_prl() should return -ENOMEM. Move the position of label "out" to return correctly. Addresses-Coverity: ("Unused value") Fixes: 300aaeeaab5f ("[IPV6] SIT: Add SIOCGETPRL ioctl to get/dump PRL.") Signed-off-by: katrinzhou Reviewed-by: Eric Dumazet Reviewed-by: David Ahern Link: https://lore.kernel.org/r/20220628035030.1039171-1-zys.zljxml@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/ipv6/sit.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c @@ -314,8 +314,6 @@ static int ipip6_tunnel_get_prl(struct i kcalloc(cmax, sizeof(*kp), GFP_KERNEL | __GFP_NOWARN) : NULL; - rcu_read_lock(); - ca = min(t->prl_count, cmax); if (!kp) { @@ -331,7 +329,7 @@ static int ipip6_tunnel_get_prl(struct i } } - c = 0; + rcu_read_lock(); for_each_prl_rcu(t->prl) { if (c >= cmax) break; @@ -343,7 +341,7 @@ static int ipip6_tunnel_get_prl(struct i if (kprl.addr != htonl(INADDR_ANY)) break; } -out: + rcu_read_unlock(); len = sizeof(*kp) * c; @@ -352,7 +350,7 @@ out: ret = -EFAULT; kfree(kp); - +out: return ret; }