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 09CAFC433EF for ; Mon, 10 Jan 2022 07:43:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240602AbiAJHnH (ORCPT ); Mon, 10 Jan 2022 02:43:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240068AbiAJHaa (ORCPT ); Mon, 10 Jan 2022 02:30:30 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDE3CC028BB8; Sun, 9 Jan 2022 23:27:48 -0800 (PST) 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 98D80B811FE; Mon, 10 Jan 2022 07:27:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3E9FC36AE9; Mon, 10 Jan 2022 07:27:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1641799667; bh=ZITSXJpqyzXFFGqs6E0wZpm/00mLeMXlZhAJ7ccawaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n0IKrJU8FiYWBIIl2b7AMoXjTXhpA3rHprcPMyHDsSoQWIl/Tgsok0S/YsYUZkhB9 EmXPUG0nN2UB/rhnw8kPq4MnYczEn4eeVq2N5LZDq5jYro0/MvwVMlQ5LBlk75LdDV OrJVS6t4+cYLYSYNeDD9i7wf5QdqstywApa0JKro= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Ahern , Nicolas Dichtel , Jakub Kicinski , Sasha Levin Subject: [PATCH 4.19 16/21] ipv6: Do cleanup if attribute validation fails in multipath route Date: Mon, 10 Jan 2022 08:23:17 +0100 Message-Id: <20220110071814.479947128@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220110071813.967414697@linuxfoundation.org> References: <20220110071813.967414697@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: David Ahern [ Upstream commit 95bdba23b5b4aa75fe3e6c84335e638641c707bb ] As Nicolas noted, if gateway validation fails walking the multipath attribute the code should jump to the cleanup to free previously allocated memory. Fixes: 1ff15a710a86 ("ipv6: Check attribute length for RTA_GATEWAY when deleting multipath route") Signed-off-by: David Ahern Acked-by: Nicolas Dichtel Link: https://lore.kernel.org/r/20220103170555.94638-1-dsahern@kernel.org Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/ipv6/route.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 8a437c20eeccd..7e3ab23fc995c 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -4466,12 +4466,10 @@ static int ip6_route_multipath_add(struct fib6_config *cfg, nla = nla_find(attrs, attrlen, RTA_GATEWAY); if (nla) { - int ret; - - ret = fib6_gw_from_attr(&r_cfg.fc_gateway, nla, + err = fib6_gw_from_attr(&r_cfg.fc_gateway, nla, extack); - if (ret) - return ret; + if (err) + goto cleanup; r_cfg.fc_flags |= RTF_GATEWAY; } -- 2.34.1