From patchwork Tue Nov 17 17:46:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 11913085 X-Patchwork-Delegate: kuba@kernel.org 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.7 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,URIBL_BLOCKED,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 897B1C63798 for ; Tue, 17 Nov 2020 17:47:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4662321734 for ; Tue, 17 Nov 2020 17:47:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730072AbgKQRrf (ORCPT ); Tue, 17 Nov 2020 12:47:35 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:56077 "EHLO wout2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729008AbgKQRrd (ORCPT ); Tue, 17 Nov 2020 12:47:33 -0500 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id D5395F3F; Tue, 17 Nov 2020 12:47:32 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Tue, 17 Nov 2020 12:47:33 -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=Rw+iMjCkI30TaA4SHluORRyAV6j71+jgGemXuMZdcTQ=; b=F6CXjTN/ pMd994TjobC4gWXXUV6Oo/1pyLtDFP88XwsP5t3tyd4C9Fw4BdktupxYBGGOHWjB MtfJzXiK+rEqPCKCSpeqrgX4Rw+kXC/NYfMg8GgvS7jAD1hDALnXdTgdMV0TkmdY cN+051DT2dH0X1pt2PMA/bTGUY9jo2PlPovVU4+YN0TpcsE/TBnAebotX3LEalvL 1ewj3zNsm9Fu1BpVipt/b+omLbzFHP/5aBbYfPIRuYbKsbAhRSZkJ9dVgC2Vtv+y sBLRuahuVOqUY/88eCSMvO/R8MRMdF11ulFEnzYAfAddU4RAgNuXu5WLKR5Ea0uH EfcEsom/9bpY+A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudeffedguddthecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpefkughoucfutghhihhmmhgvlhcuoehiughoshgthhesihgu ohhstghhrdhorhhgqeenucggtffrrghtthgvrhhnpeduteeiveffffevleekleejffekhf ekhefgtdfftefhledvjefggfehgfevjeekhfenucfkphepkeegrddvvdelrdduheegrddu geejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepih guohhstghhsehiughoshgthhdrohhrgh X-ME-Proxy: Received: from shredder.lan (igld-84-229-154-147.inter.net.il [84.229.154.147]) by mail.messagingengine.com (Postfix) with ESMTPA id 1DD58328005E; Tue, 17 Nov 2020 12:47:30 -0500 (EST) From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, jiri@nvidia.com, dsahern@gmail.com, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 1/9] mlxsw: spectrum_router: Fix wrong kfree() in error path Date: Tue, 17 Nov 2020 19:46:56 +0200 Message-Id: <20201117174704.291990-2-idosch@idosch.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201117174704.291990-1-idosch@idosch.org> References: <20201117174704.291990-1-idosch@idosch.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ido Schimmel The function allocates 'nhgi', not 'nh_grp', so it needs to free the former in its error path. Fixes: 7f7a417e6a11 ("mlxsw: spectrum_router: Split nexthop group configuration to a different struct") Addresses-Coverity: ("Memory - corruptions (USE_AFTER_FREE)") Reviewed-by: Jiri Pirko Signed-off-by: Ido Schimmel --- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index a2e81ad5790f..7dbf02f45913 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -5423,7 +5423,7 @@ mlxsw_sp_nexthop6_group_info_init(struct mlxsw_sp *mlxsw_sp, nh = &nhgi->nexthops[i]; mlxsw_sp_nexthop6_fini(mlxsw_sp, nh); } - kfree(nh_grp); + kfree(nhgi); return err; }