Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4137971pxb; Mon, 8 Feb 2021 08:48:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJxgClF/Oq+KZR+WytpSOKzqG43WJgOHqmMjhrBfo+BybpXdYqxQZ4vGNK/XPHqv5+Ua0CYX X-Received: by 2002:a17:906:2a8b:: with SMTP id l11mr17810613eje.1.1612802920918; Mon, 08 Feb 2021 08:48:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612802920; cv=none; d=google.com; s=arc-20160816; b=nXYcNWijQs3eD1T6y/VhX6LO4eG5sXQxjgsDjXRu5Iuv9z1d6btfmA/+GsnaE3dBdv 7j1RFY+Npauwgd/z6JWo8wgd3r8gxVVuusDkUyNaYPGSysPV8ZWnEleGEQ+nn5T+fQnL gjhZsgJDo0WwbqEl16o1itigRSy6R+4Dk5fmUkb/SfnpvIdX60INuTyuRw/Jk0jjLFX2 MayII5ulVLSDaTYEnXq/tBbUJ3JBtZKlo5Zq7aTqKwjETd/6lXZh1/7YHsbRSelG7r/A ehxl0vCAgZeM091coqjFHCR03HFdb2XhksIio08ewZWbVwW03RMg6xvgPpT4XUk7yAYE GJKA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=j1j0xo7RBInnR2D5uPo/AqsCuk/OnhjmuEhJs3lNRcg=; b=L5laQMGoxz6G5tFYxYLtuKC3u9c0NZzMT6Fid3666cJ8g/1XnECuWGJGJkWTmhZGkJ pgs79qcNK9fh2e6THSXVk6FJBHWSzqs6BC7LLjVIBumHabouPl0c3Drjss6rnJ7GJorA ccZa3TpkN+Z+czYjpQTdp4QCCBsotMdNGBRjwaeGOqtZGkYEimn5lEUsJ1THYTSpOlps 9McVr9HU3OXu0r7pNqOBnM82Pb5yS/yhMNPfu7br+La4DjQNR8HB7qjX7qL6PJCd6OA7 279F/ESaZE9Ps8D3NSA/g8rwJVE/N1InAt6jMwidUob5b7dEAJO91YTtJcyW0I+9qmsj PEkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YzBEG7h1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bg8si13168609ejb.155.2021.02.08.08.48.15; Mon, 08 Feb 2021 08:48:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YzBEG7h1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232115AbhBHQo4 (ORCPT + 99 others); Mon, 8 Feb 2021 11:44:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:58716 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230303AbhBHPP7 (ORCPT ); Mon, 8 Feb 2021 10:15:59 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 85D3464ED1; Mon, 8 Feb 2021 15:11:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612797074; bh=vJw3/se5p5IgzQrAXmzA1rjxPEZXb6shSptwNaI/XTw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YzBEG7h1+E+q4P/zvUohbI7BSbysqBI+m1uh0g49k1EpGeXe15pCQeX+U2imPoUK2 7mq0nWwPmiHAPr3G7UV8j+fmsZR6zAJBhPF7iVdnDnIiCyx/p+F+JHpSzTAuz5JlEu 6neRtrxgQaKWJpKIi5B9aPMXs2Ryh6Ve12ZGl9f0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maor Gottlieb , Alaa Hleihel , Mark Bloch , Saeed Mahameed , Sasha Levin Subject: [PATCH 5.4 16/65] net/mlx5: Fix leak upon failure of rule creation Date: Mon, 8 Feb 2021 16:00:48 +0100 Message-Id: <20210208145810.873577004@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208145810.230485165@linuxfoundation.org> References: <20210208145810.230485165@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maor Gottlieb [ Upstream commit a5bfe6b4675e0eefbd9418055b5cc6e89af27eb4 ] When creation of a new rule that requires allocation of an FTE fails, need to call to tree_put_node on the FTE in order to release its' resource. Fixes: cefc23554fc2 ("net/mlx5: Fix FTE cleanup") Signed-off-by: Maor Gottlieb Reviewed-by: Alaa Hleihel Reviewed-by: Mark Bloch Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c index 4944c40436f08..11e12761b0a6e 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c @@ -1697,6 +1697,7 @@ search_again_locked: if (!fte_tmp) continue; rule = add_rule_fg(g, spec, flow_act, dest, dest_num, fte_tmp); + /* No error check needed here, because insert_fte() is not called */ up_write_ref_node(&fte_tmp->node, false); tree_put_node(&fte_tmp->node, false); kmem_cache_free(steering->ftes_cache, fte); @@ -1745,6 +1746,8 @@ skip_search: up_write_ref_node(&g->node, false); rule = add_rule_fg(g, spec, flow_act, dest, dest_num, fte); up_write_ref_node(&fte->node, false); + if (IS_ERR(rule)) + tree_put_node(&fte->node, false); return rule; } rule = ERR_PTR(-ENOENT); @@ -1844,6 +1847,8 @@ search_again_locked: up_write_ref_node(&g->node, false); rule = add_rule_fg(g, spec, flow_act, dest, dest_num, fte); up_write_ref_node(&fte->node, false); + if (IS_ERR(rule)) + tree_put_node(&fte->node, false); tree_put_node(&g->node, false); return rule; -- 2.27.0