From patchwork Sun Dec 24 08:13:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhipeng Lu X-Patchwork-Id: 183034 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp2034056dyi; Sun, 24 Dec 2023 00:15:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IFkvi2CKyD3dB0IyLZlFHYDu6SbnW/Cxt3V3+bIQOC2oPwh3TGGQLy8OT49cBGzfLlRbFT/ X-Received: by 2002:a05:6808:38c3:b0:3bb:a0e2:8d51 with SMTP id el3-20020a05680838c300b003bba0e28d51mr1579035oib.2.1703405711616; Sun, 24 Dec 2023 00:15:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703405711; cv=none; d=google.com; s=arc-20160816; b=rdiCRSkPv+NM2j/AlsYrPSgyw07IUTsRKcNtLDaA5FXO1nvjyQxfKAKWD9HmBaRfJt nMfm7FxQ7+daWgRTwgbZevlFW5GjLXi+F3OReYymRw4Zr5uTjF9I01cGRSVbIV47t9Hq /OBOrxhLr3IiOpYAh0wTXG+AUvBK6bGRUkMUjajCfv+8XHdZ74aPZToD0SBks5lAyhEd u+1UkenSA0everN1L5x1RmUDSHtn/JRvZBUqGhogmf28UgCgOQPIJjje68CWu4vMUQOj QA2NoDMWY7W5PlDDVb63erR4NUL/2Kur/rCa02lOGnnR+mqopX3JwfzP2tCpydDDOFTY 6OvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=Od0uX9evnS2w6lLd69OZ/spnKiWNoiPN5Kis1sIWx9M=; fh=/Gu90RCdx+gNxSpHGyvqQQX/gt6LIkzdEDoQg/3nweQ=; b=jhG/jyFrSm9qraL+Oc9NL6o9JN0QuCh7r8Zi1/q6pdPYazUrU8Lj1qihCT5fo8DzHe 5rvU4UT+5N2vZ6p1asxQBiWxx5N86ZJEhNwkqDYpF02QPmnj71dhheTSVAtdK6LdpWs8 X46VwO0YgczO/CcHbsft15KVD7gZDEZNcXj08HNyRYMqG5+35ryOrnhtWv51ilCJhl+m EwR/h5UlugWQmumlutWb7aAsD4nWHzlpucTO1PD4Sg/Kqpg8QzYEt7moVROVkwCQnnHh XqBbK0Mi0WQUd0fCZlNv1vngBsbRrV1q2K/LCDdncV0qFwOEHeqYmsjkHvyA3zuf0jQI RpsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-10654-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10654-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id y4-20020aa78044000000b006d983f1b146si4162208pfm.274.2023.12.24.00.15.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 00:15:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10654-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-10654-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10654-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 6C9AEB2129A for ; Sun, 24 Dec 2023 08:15:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9005E23C3; Sun, 24 Dec 2023 08:14:45 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from zg8tmtu5ljg5lje1ms4xmtka.icoremail.net (zg8tmtu5ljg5lje1ms4xmtka.icoremail.net [159.89.151.119]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF4A91383; Sun, 24 Dec 2023 08:14:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zju.edu.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zju.edu.cn Received: from luzhipeng.223.5.5.5 (unknown [39.174.92.167]) by mail-app3 (Coremail) with SMTP id cC_KCgA3ro1U6IdlArdjAQ--.38379S2; Sun, 24 Dec 2023 16:14:13 +0800 (CST) From: Zhipeng Lu To: alexious@zju.edu.cn Cc: Saeed Mahameed , Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maor Gottlieb , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net/mlx5e: fix a double-free in arfs_create_groups Date: Sun, 24 Dec 2023 16:13:48 +0800 Message-Id: <20231224081348.3535146-1-alexious@zju.edu.cn> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: cC_KCgA3ro1U6IdlArdjAQ--.38379S2 X-Coremail-Antispam: 1UD129KBjvdXoW7Gry3CFWUAF4fGr4UAF4ruFg_yoWDWrg_CF 1UXwn5Cwn0vr4Ykw43WrZ8XrWIkr4qgrnayFZIgFy5Jw4UWryxZ3yxWa4fXF4xWFy8X3ZI y343tF13u34UAjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbx8FF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j 6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628v n2kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F4 0E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFyl IxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxV AFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j 6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUdHU DUUUUU= X-CM-SenderInfo: qrsrjiarszq6lmxovvfxof0/ X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786150347478267593 X-GMAIL-MSGID: 1786150347478267593 When `in` allocated by kvzalloc fails, arfs_create_groups will free ft->g and return an error. However, arfs_create_table, the only caller of arfs_create_groups, will hold this error and call to mlx5e_destroy_flow_table, in which the ft->g will be freed again. Fixes: 1cabe6b0965e ("net/mlx5e: Create aRFS flow tables") Signed-off-by: Zhipeng Lu Reviewed-by: Simon Horman --- drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c index bb7f86c993e5..d9a60bd04167 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c @@ -257,6 +257,7 @@ static int arfs_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; }