Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2724909rwb; Sun, 20 Nov 2022 00:01:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf6msTJHWsb7zMpiHbmZcnXIxxp3JSET0iBldLn2N/nST60nNujKQPezAbUeL8uFzZzyCI3Z X-Received: by 2002:aa7:d0d4:0:b0:461:b1b9:bed0 with SMTP id u20-20020aa7d0d4000000b00461b1b9bed0mr3407970edo.122.1668931294673; Sun, 20 Nov 2022 00:01:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668931294; cv=none; d=google.com; s=arc-20160816; b=mZ7FB5BJ/8jibR5VepDsl82iGrERvuPSvr+33RYkzvmRrkBe9YAh8/tYrv34efmA1g CIVi4HMMmyzykfnUrm0r5oUKCbsb1pcwFAjyg7j0jd3QCPwxToA9hNBicGzr7VA2mrPp V5UwFi+S6oS8G6VePDVAScuQi2nRR/5jy6S96YUYBgXaMwcV47sXI/vdaBsa5VlFdZrI UX4dyL+xViWNHY+SR1Vh4zwFstF/8aaNWsXXX2tE5SMcqxR8cuf4OsVatvpvXM06RJOX hBaNtorBTXCdzv65t/D7j6L8OIUHMNGSmXdxPGm2FEDD7RMW9KsDUpi1DGa4O8BCRXt2 4JSQ== 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 :message-id:date:subject:cc:to:from; bh=oL4g0P2eKLL9NH9ogDIwqMhpWzQ2ZIPBv7GUzEY7vpo=; b=PQnNVN9PXycgwvBvYMS+6lNLf6Y1HP9vt8Ow8gWtJaSu7vY7o17DSqyt2Fab2USGjb 9HJO1R71dCFX/ehw8/bu+HppaCXcwCGbHqljLtatf4Uwr+M1NOdqT952uXrfirnW8+J3 5b58j9LWmTAp2MJiC9d/2UVrK3aHn9NHTRjV31wHACK4oibsIjRTOJAw6zRRjJg8uj5s /di5Fkz3KHuh/iPBCOPu9lxTrW/YWrFPa5TI5jpKQw7abm+I5EajjOVfuW9Sf4LiZDAN uaQz53rSofFBM5AROe1r2wk9mnXMi+Lp0/OUQSfF6FB3StVFfdsYx1lQ4xri6XBhQknz r/dg== 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb22-20020a1709071c9600b0073daf6b44a5si7326646ejc.775.2022.11.20.00.01.03; Sun, 20 Nov 2022 00:01:34 -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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229519AbiKTH2t (ORCPT + 92 others); Sun, 20 Nov 2022 02:28:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229446AbiKTH2r (ORCPT ); Sun, 20 Nov 2022 02:28:47 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60D941409F; Sat, 19 Nov 2022 23:28:44 -0800 (PST) Received: from canpemm500006.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NFMZ63RWSzmVbw; Sun, 20 Nov 2022 15:28:14 +0800 (CST) Received: from localhost.localdomain (10.175.104.82) by canpemm500006.china.huawei.com (7.192.105.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sun, 20 Nov 2022 15:28:41 +0800 From: Ziyang Xuan To: , , , , , , CC: Subject: [PATCH net] ipv4: Fix error return code in fib_table_insert() Date: Sun, 20 Nov 2022 15:28:38 +0800 Message-ID: <20221120072838.2167047-1-william.xuanziyang@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.82] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500006.china.huawei.com (7.192.105.130) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,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 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 --- 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 452ff177e4da..f26d5ac117d6 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c @@ -1381,8 +1381,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.25.1