From patchwork Thu Jan 7 14:48:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 358708 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 544F8C433E6 for ; Thu, 7 Jan 2021 14:49:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 240CE217A0 for ; Thu, 7 Jan 2021 14:49:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728468AbhAGOtz (ORCPT ); Thu, 7 Jan 2021 09:49:55 -0500 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:38847 "EHLO wout1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727753AbhAGOtz (ORCPT ); Thu, 7 Jan 2021 09:49:55 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id BC59C1850; Thu, 7 Jan 2021 09:49:08 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 07 Jan 2021 09:49:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=G3k0Af7NmpKDN68SDhDcQ4gAWdNN8kOpme1/dP8Y2Og=; b=BcWqYacY tnjeNremnWaNxwhqEkCUbThFlvDv3ay+PL9hMmopaYtUKmAlvFJOueSqA7+iRDPR LA0SMb+jhI7vhKi2Dy2P5e7MTs+dALcbzfU6NWb4/0nwiuDg5suoTo/rEeE1Nnsz V47BEfE+0sPMCEFu9H3crx1MgW4i0jfSPEN7ADrkK49LIQD3xP3eqmDc5hm8nWs/ LlpExwzre8Zvle7l893IX6jlv9QOrj4Ah8RPkodtTCscXf4WaSVYRgKF/MC/HlEC 8rP7fuzDrxfkZuLu1JoCK8In+QMlCVh6UHcPnrWnd8UzNxOE3c37djX4HbmVRgq9 icB/wt17VeYLhg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrvdegvddgieelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepkfguohcuufgthhhimhhmvghluceoihguohhstghhsehiugho shgthhdrohhrgheqnecuggftrfgrthhtvghrnhepudetieevffffveelkeeljeffkefhke ehgfdtffethfelvdejgffghefgveejkefhnecukfhppeekgedrvddvledrudehfedrgeeg necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihguoh hstghhsehiughoshgthhdrohhrgh X-ME-Proxy: Received: from shredder.lan (igld-84-229-153-44.inter.net.il [84.229.153.44]) by mail.messagingengine.com (Postfix) with ESMTPA id DE2E1108005C; Thu, 7 Jan 2021 09:49:05 -0500 (EST) From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, petrm@nvidia.com, dsahern@gmail.com, roopa@nvidia.com, nikolay@nvidia.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net 1/4] nexthop: Fix off-by-one error in error path Date: Thu, 7 Jan 2021 16:48:21 +0200 Message-Id: <20210107144824.1135691-2-idosch@idosch.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210107144824.1135691-1-idosch@idosch.org> References: <20210107144824.1135691-1-idosch@idosch.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ido Schimmel A reference was not taken for the current nexthop entry, so do not try to put it in the error path. Fixes: 430a049190de ("nexthop: Add support for nexthop groups") Signed-off-by: Ido Schimmel Reviewed-by: Petr Machata --- net/ipv4/nexthop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c index 5e1b22d4f939..f8035cfa9c20 100644 --- a/net/ipv4/nexthop.c +++ b/net/ipv4/nexthop.c @@ -1459,7 +1459,7 @@ static struct nexthop *nexthop_create_group(struct net *net, return nh; out_no_nh: - for (; i >= 0; --i) + for (i--; i >= 0; --i) nexthop_put(nhg->nh_entries[i].nh); kfree(nhg->spare);