From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4277713AE7 for ; Wed, 5 Jul 2023 17:58:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFAD8C433C9; Wed, 5 Jul 2023 17:58:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688579897; bh=AiOvjIWc6l7HOJCJDI3ZP1yivqFs7OHnrnSUUXcRC8o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vDo+BHKAMNcVHjOSh+mb5pw/nXF8TVfFIGTVAXM3Ip03D8ZYtuD9R+ofUiigL/mS9 fVydhTZIZ0rYUgUYXjMBP0wGwXNGABcH00eFIiaZfIG7tdl2FgpyjdoT2AiprBkIVe RWZ6u/lcUJOxauWkqeJWf6S4QwWumimWwAfIf41IT9KtqT7NwCzSFvt5bHsRSbMZ5U FDFy/5agxCCnzH8Gsg+aVnMdZrT/V/tyopaGzezkhpbWBKMUyeKEh5jzKnAdw2ftnO tZ3I18AL+46n8xSyOKNu9/HFFo3KZAzLVEw/u2cPCrNkoXw4qbgXZ/ZAstqSfSStVs zb5qYXYHBIiHA== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: Saeed Mahameed , netdev@vger.kernel.org, Tariq Toukan , Zhengchao Shao , Simon Horman , Rahul Rameshbabu Subject: [net V2 2/9] net/mlx5e: fix memory leak in mlx5e_fs_tt_redirect_any_create Date: Wed, 5 Jul 2023 10:57:50 -0700 Message-ID: <20230705175757.284614-3-saeed@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230705175757.284614-1-saeed@kernel.org> References: <20230705175757.284614-1-saeed@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Zhengchao Shao The memory pointed to by the fs->any pointer is not freed in the error path of mlx5e_fs_tt_redirect_any_create, which can lead to a memory leak. Fix by freeing the memory in the error path, thereby making the error path identical to mlx5e_fs_tt_redirect_any_destroy(). Fixes: 0f575c20bf06 ("net/mlx5e: Introduce Flow Steering ANY API") Signed-off-by: Zhengchao Shao Reviewed-by: Simon Horman Reviewed-by: Rahul Rameshbabu Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c b/drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c index 03cb79adf912..be83ad9db82a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c @@ -594,7 +594,7 @@ int mlx5e_fs_tt_redirect_any_create(struct mlx5e_flow_steering *fs) err = fs_any_create_table(fs); if (err) - return err; + goto err_free_any; err = fs_any_enable(fs); if (err) @@ -606,8 +606,8 @@ int mlx5e_fs_tt_redirect_any_create(struct mlx5e_flow_steering *fs) err_destroy_table: fs_any_destroy_table(fs_any); - - kfree(fs_any); +err_free_any: mlx5e_fs_set_any(fs, NULL); + kfree(fs_any); return err; } -- 2.41.0