From patchwork Wed Jan 24 08:18:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 13528784 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 2224A17981 for ; Wed, 24 Jan 2024 08:19:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706084366; cv=none; b=pUqeSXsPFcmnPizZBkV1rm0yCyUvKSIhDHhUlfnqdlgAh7gVaGARwF8AKKsByY2HTtcSQIWXZzZSab6aKeQMWXdL/BePSckAbSRpYwQS+db/Plw5DKK7iZzS+3ZVziR01uGzHoEDlO/qiRqsIlDFDPZC9MQ3Yif6FiD8mcGE1/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706084366; c=relaxed/simple; bh=PjhP0ty/XS8ftOladW2pA+IKxh62A5osh5tBpeB0hTA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tmU7uaHP5V0k8y4HF0eGBix+WZ8cltJPt8Wb1RFw4+7y/qAPT2glH5MVh1YQQI1MNEIzpJT9QMCfjB44bZK8KcLObFgIbxl5Q46F1IiU1TA6bl8HUl1DZLbuAai9PavMqA4ZJqmsWdBTkScEnq+EnYzddmpxSXVaKQ/llluobt0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oGVqDNlO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oGVqDNlO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFBA9C433F1; Wed, 24 Jan 2024 08:19:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706084365; bh=PjhP0ty/XS8ftOladW2pA+IKxh62A5osh5tBpeB0hTA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oGVqDNlON2/mYL/wFSa3p/LXXO/XzHId+waI1slut18aQ3ArfGTlZ/CdXWGyi4bEc CweRjcgR6EwcK07foTSl5UeYpQRx8LpuvGFt7hrTItNgOKjuZcxODnCczWmGPNMnb2 gouXeTQP/n8u3Ek/UtL2t73ukdeSxpr0P7eZuA1r8UmVTRimM/dHRtE+dv64jCv2Xp J4xK8bSAfnnoD6RZjBhtxf+MdhjZPIbI1SVpuGd1grHd8pbDEhS2/NXRyi4MRsQWUM isbaV6AyDAn51FEbjyCyDOx3E3/mHC23gPQ+ftWQUGCqIF6pWpCCBTpLKJCpPQDLp6 I+dYC7mjfeQrw== 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 14/14] net/mlx5e: fix a potential double-free in fs_any_create_groups Date: Wed, 24 Jan 2024 00:18:55 -0800 Message-ID: <20240124081855.115410-15-saeed@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240124081855.115410-1-saeed@kernel.org> References: <20240124081855.115410-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_any_create_groups() will free ft->g. However, its caller fs_any_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_any_create_groups(). Fixes: 0f575c20bf06 ("net/mlx5e: Introduce Flow Steering ANY 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 e1283531e0b8..671adbad0a40 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 @@ -436,6 +436,7 @@ static int fs_any_create_groups(struct mlx5e_flow_table *ft) in = kvzalloc(inlen, GFP_KERNEL); if (!in || !ft->g) { kfree(ft->g); + ft->g = NULL; kvfree(in); return -ENOMEM; }