From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 055DA6FA1 for ; Wed, 30 Nov 2022 18:38:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BE69C433D6; Wed, 30 Nov 2022 18:38:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1669833480; bh=+IxhaEtM4URwruUoh5XoA1j99yFakBL/THQsyyEISC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dxpXKUah8STGZKS8o2XfM0uizBL1+3Oip2gd9q4Qx36qy7e75zuu/VynCo8Lwk/cl XDbNMJayDFc7yp695R41BaKZTzTEACiDP1C+XWy+/sT0UE+5nW9XXQY3ekDweoxW3j pAyuFGDT28sqdSxdMDqjR+4Om/GuvP9MRInS6Qec= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ziyang Xuan , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 121/206] ipv4: Fix error return code in fib_table_insert() Date: Wed, 30 Nov 2022 19:22:53 +0100 Message-Id: <20221130180536.127431707@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221130180532.974348590@linuxfoundation.org> References: <20221130180532.974348590@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Ziyang Xuan [ Upstream commit 568fe84940ac0e4e0b2cd7751b8b4911f7b9c215 ] In fib_table_insert(), if the alias was already inserted, but node not exist, the error code should be set before return from error handling path. Fixes: a6c76c17df02 ("ipv4: Notify route after insertion to the routing table") Signed-off-by: Ziyang Xuan Link: https://lore.kernel.org/r/20221120072838.2167047-1-william.xuanziyang@huawei.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/ipv4/fib_trie.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index 19c6e7b93d3d..52f9f69f57b3 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c @@ -1375,8 +1375,10 @@ int fib_table_insert(struct net *net, struct fib_table *tb, /* The alias was already inserted, so the node must exist. */ l = l ? l : fib_find_node(t, &tp, key); - if (WARN_ON_ONCE(!l)) + if (WARN_ON_ONCE(!l)) { + err = -ENOENT; goto out_free_new_fa; + } if (fib_find_alias(&l->leaf, new_fa->fa_slen, 0, 0, tb->tb_id, true) == new_fa) { -- 2.35.1