From patchwork Sun Nov 20 07:28:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ziyang Xuan X-Patchwork-Id: 23385 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1015451wrr; Sat, 19 Nov 2022 23:43:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf4HwHxEnQLc2YJlVWDpg8VsM0beYF28SenWJP7QcoxEEoGHvH4AZgqdmdoawxxMbL7LkoY5 X-Received: by 2002:a17:902:f78c:b0:187:a98:7ee5 with SMTP id q12-20020a170902f78c00b001870a987ee5mr676886pln.142.1668930195380; Sat, 19 Nov 2022 23:43:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668930195; cv=none; d=google.com; s=arc-20160816; b=rWLbhFWZ2R8UUkqlXT/6r/E/ibFc4b/hsGvXCf6q4umn4LjhyHk60br85WshERXe0w InXto8akZJFXWCplW8dwH/EN/aUHGepMYWCaRMJ5JpbEmmstEmFuzRTw5PUxvf4cLEN2 FFOPz6kONlrzTpQM8DS6mw+UM2+ZvZo3dJw5OIAmgw/L2uKlBr5I882yhpIWvLWzEWX4 EhhoVkT07ITaNelc3MMlVbQm1nkzuDVCpcU/T2ZQaa93qB5WxuqifymUQ6jNFIeCUH2q VsP6T6qY3RRS/bBF/KOJoXvCtfS5jp4rNBOXOEMacI21l9AohnZ2zkeRZW69ewMwck8u 6i1w== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t15-20020a654b8f000000b00460dd0eed0csi9469289pgq.176.2022.11.19.23.42.49; Sat, 19 Nov 2022 23:43:15 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750000148244802016?= X-GMAIL-MSGID: =?utf-8?q?1750000148244802016?= 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) {