From patchwork Thu Jan 7 20:28:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 358674 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=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 D8F4BC433E0 for ; Thu, 7 Jan 2021 20:30:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 972AA235F7 for ; Thu, 7 Jan 2021 20:30:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727669AbhAGUaV (ORCPT ); Thu, 7 Jan 2021 15:30:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:55664 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727555AbhAGUaU (ORCPT ); Thu, 7 Jan 2021 15:30:20 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 670BD235FA; Thu, 7 Jan 2021 20:29:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610051357; bh=OdKoz1arEP7iap2o2AyJ2AHvTY2yJJbfIaitguX/GsY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UP8ZYqW8SiAkbD6uvkrMQivJ6oi90Zka1HzdaKn1xbN5cyhMThfe4Bqd3Rz1moMoc IFrDJIanL6+KIl3bi8ZqCX034T5ao+vqN1I5DIDtiBmuF0L/zXoDRmrokURL+KyuUu zptOjLAlsC9dP8A9XHejAiiGADjg5nCOOViWmjc29AwNQWvxaY1aiqVTP//cC4k2lb 5wPNHknOz5QPXDyVW7GONa+mmRFDYabr/N9HUIdtGHoBsoL8Lqq6nw/anv/j0lPBQ3 ZsiL00NWMuLuiLKvqqcSAVyyHb1/DAEib2KnWzowElLz9mrxlwYG1bfs6gKxfAhZJ9 wIQ5uS71T+cBA== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Dinghao Liu , Leon Romanovsky , Saeed Mahameed Subject: [net 10/11] net/mlx5e: Fix two double free cases Date: Thu, 7 Jan 2021 12:28:44 -0800 Message-Id: <20210107202845.470205-11-saeed@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210107202845.470205-1-saeed@kernel.org> References: <20210107202845.470205-1-saeed@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Dinghao Liu mlx5e_create_ttc_table_groups() frees ft->g on failure of kvzalloc(), but such failure will be caught by its caller in mlx5e_create_ttc_table() and ft->g will be freed again in mlx5e_destroy_flow_table(). The same issue also occurs in mlx5e_create_ttc_table_groups(). Set ft->g to NULL after kfree() to avoid double free. Fixes: 7b3722fa9ef6 ("net/mlx5e: Support RSS for GRE tunneled packets") Fixes: 33cfaaa8f36f ("net/mlx5e: Split the main flow steering table") Signed-off-by: Dinghao Liu Reviewed-by: Leon Romanovsky Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/en_fs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c index fa8149f6eb08..44a2dfbc3853 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c @@ -942,6 +942,7 @@ static int mlx5e_create_ttc_table_groups(struct mlx5e_ttc_table *ttc, in = kvzalloc(inlen, GFP_KERNEL); if (!in) { kfree(ft->g); + ft->g = NULL; return -ENOMEM; } @@ -1087,6 +1088,7 @@ static int mlx5e_create_inner_ttc_table_groups(struct mlx5e_ttc_table *ttc) in = kvzalloc(inlen, GFP_KERNEL); if (!in) { kfree(ft->g); + ft->g = NULL; return -ENOMEM; }