From patchwork Thu Dec 14 01:24:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 13492174 X-Patchwork-Delegate: kuba@kernel.org 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 4A9F120FD for ; Thu, 14 Dec 2023 01:25:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cPKhm4R6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D646C433C8; Thu, 14 Dec 2023 01:25:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702517115; bh=9T9QHaoh6mWfJN3/UJbdkADFOKI/+NYHb6NSMgMVk28=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cPKhm4R64Kms5NKlMPY2lcCqiV3QGaLORfooCIU7LVb0UkJjHaJHYiJWXUlDv3fvi qADCGqUowMPeG39Cv22AqMqTLe+SnQofKQlnpumTZvIlTtzJ2im5SJNp516xMTb+XI FvD1HZV6FKYPPMn+vWx7TlBUmazqpswfAzmqlBjTUaij+qNw23SdZ+252V02AOFQPg PCdvUOS+SaJ4SkC75AWoUIxBQOGkNZVDaU/KFJodjZGHQ9zjAMBTJxHRJ/VC2lquhc ZkEGPMqTMbnAAPhAjyCDR03M/dOByorNokDnTcP0F+OY61YyXlGX7L5H7iqjiSSKu/ 9okXTs19HuJJw== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: Saeed Mahameed , netdev@vger.kernel.org, Tariq Toukan , Dinghao Liu , Simon Horman Subject: [net 06/15] net/mlx5e: fix a potential double-free in fs_udp_create_groups Date: Wed, 13 Dec 2023 17:24:56 -0800 Message-ID: <20231214012505.42666-7-saeed@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231214012505.42666-1-saeed@kernel.org> References: <20231214012505.42666-1-saeed@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Dinghao Liu When kcalloc() for ft->g succeeds but kvzalloc() for in fails, fs_udp_create_groups() will free ft->g. However, its caller fs_udp_create_table() will free ft->g again through calling mlx5e_destroy_flow_table(), which will lead to a double-free. Fix this by setting ft->g to NULL in fs_udp_create_groups(). Fixes: 1c80bd684388 ("net/mlx5e: Introduce Flow Steering UDP API") Signed-off-by: Dinghao Liu Reviewed-by: Tariq Toukan Reviewed-by: Simon Horman Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c | 1 + 1 file changed, 1 insertion(+) 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 be83ad9db82a..e1283531e0b8 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 @@ -154,6 +154,7 @@ static int fs_udp_create_groups(struct mlx5e_flow_table *ft, enum fs_udp_type ty in = kvzalloc(inlen, GFP_KERNEL); if (!in || !ft->g) { kfree(ft->g); + ft->g = NULL; kvfree(in); return -ENOMEM; }