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 00228C433EF for ; Tue, 5 Jul 2022 12:02:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233270AbiGEMC2 (ORCPT ); Tue, 5 Jul 2022 08:02:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232981AbiGEMBY (ORCPT ); Tue, 5 Jul 2022 08:01:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 408701835F; Tue, 5 Jul 2022 05:01:23 -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 C2879B817D3; Tue, 5 Jul 2022 12:01:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B5A9C36AE3; Tue, 5 Jul 2022 12:01:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657022480; bh=FnF83P0Me1TTViQOm7a/P8GEvR4lEBNIGtf5qJLmVJM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tkvKMPcU+7u83dyBUR+GG6Fv5byeba0LX9cZgjCtUp2YjmXW4VmkL2q0Bdn89OQ01 P41ySJLYWEVDmbBbhhb6asLbUtprG0v6gSlhd1g0OOONwIU651PBdSJRYdN6OnhhXR ekVvykQWmgp05oQ+uYbboKw24ttQsRI22SwSc2J0= 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.14 21/29] ipv6/sit: fix ipip6_tunnel_get_prl return value Date: Tue, 5 Jul 2022 13:58:09 +0200 Message-Id: <20220705115606.969644195@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220705115606.333669144@linuxfoundation.org> References: <20220705115606.333669144@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 @@ -308,8 +308,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) { @@ -325,7 +323,7 @@ static int ipip6_tunnel_get_prl(struct i } } - c = 0; + rcu_read_lock(); for_each_prl_rcu(t->prl) { if (c >= cmax) break; @@ -337,7 +335,7 @@ static int ipip6_tunnel_get_prl(struct i if (kprl.addr != htonl(INADDR_ANY)) break; } -out: + rcu_read_unlock(); len = sizeof(*kp) * c; @@ -346,7 +344,7 @@ out: ret = -EFAULT; kfree(kp); - +out: return ret; }