From patchwork Mon Dec 5 07:38:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Changzhong X-Patchwork-Id: 29573 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2114456wrr; Sun, 4 Dec 2022 23:44:00 -0800 (PST) X-Google-Smtp-Source: AA0mqf5wUHbDRGiJDuuT4GZ5mq7pBcmIaRaA09PoXVs7PW/z6b1zvWA2QrjWYsTU1nVrBUStJki1 X-Received: by 2002:a17:906:a146:b0:7a7:bf8c:1824 with SMTP id bu6-20020a170906a14600b007a7bf8c1824mr4181986ejb.767.1670226240363; Sun, 04 Dec 2022 23:44:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670226240; cv=none; d=google.com; s=arc-20160816; b=JlgU8M/Bb/ZPklkI22cvegTd7+PshleRHbNEe7+XMhQ/HP4oolTExX74fJ7rBxPcXn GDtmyxnoOyj8/wW1afOuImh8GAWF9PdtK5cKUkEN2D2DRHph74k8rn2lKiAujDfXw4IV etsE3384XRs0My6Llb7DFhVTyzvZbQwlLHqhzS/eL3CVFakpkV+3ZiRorQSfoGDnyUSv qiodxdypaZA+hI3g3viniHrEw/EfWwzflzXUf5Je2T3/PZ3upkXKdKDQq3bXtUW4IZ9D FMoXEYvfX/nR42iJZsP8r7+U7Tu7ND4gXxmjiOfH10Ul3ufSJ0BO8WupmD5Mn5YBqZKB cETQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=JJ1nIJyBTj/HDHns+WuHa0joo35//HGm6nwurKdbcBg=; b=j/vK1Ma0yr4ebkaErEf4fW2nIPEkB5KzMY57HzJGAPVaNFx5d59MrGTkhQFn+hJNjL /NrpntDfORcuc9AdPhfTrFqC9v9YlXve68cQtndWSJeluE91zARt1DeU8393OBJvnkpA NKCKe5Jr2FtqFNUmKphirUHP/CvWmhEun7iwk+mb1KrhePiLLI2ZYNpeEEjRQdfdkC48 LSBlc/B7+1qhyMWyOMwoe4EK9Jvdbs8oyvEL8mepdhduiaj9fOlWjtOWg8vnfQ5jJPc5 uvbcOYSblnFcmkJpAY7noMm22992d19Zhi/lqYyxX5F21B97u958tRj4QdvXWDQ2XAqb PdcA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp12-20020a1709073e0c00b007c0dcc41dbcsi4175765ejc.821.2022.12.04.23.43.36; Sun, 04 Dec 2022 23:44:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231765AbiLEHip (ORCPT + 99 others); Mon, 5 Dec 2022 02:38:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230037AbiLEHin (ORCPT ); Mon, 5 Dec 2022 02:38:43 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7349B4A7; Sun, 4 Dec 2022 23:38:41 -0800 (PST) Received: from dggpeml500006.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NQb1C2k6QzkXnx; Mon, 5 Dec 2022 15:35:11 +0800 (CST) Received: from localhost.localdomain (10.175.112.70) by dggpeml500006.china.huawei.com (7.185.36.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 5 Dec 2022 15:38:39 +0800 From: Zhang Changzhong To: Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michal Swiatkowski CC: Zhang Changzhong , , Subject: [PATCH net] ice: switch: fix potential memleak in ice_add_adv_recipe() Date: Mon, 5 Dec 2022 15:38:22 +0800 Message-ID: <1670225902-10923-1-git-send-email-zhangchangzhong@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.175.112.70] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpeml500006.china.huawei.com (7.185.36.76) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751359149993463090?= X-GMAIL-MSGID: =?utf-8?q?1751359149993463090?= When ice_add_special_words() fails, the 'rm' is not released, which will lead to a memory leak. Fix this up by going to 'err_unroll' label. Compile tested only. Fixes: 8b032a55c1bd ("ice: low level support for tunnels") Signed-off-by: Zhang Changzhong Reviewed-by: Leon Romanovsky Reviewed-by: Jiri Pirko --- drivers/net/ethernet/intel/ice/ice_switch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethernet/intel/ice/ice_switch.c index 9b762f7..61f844d 100644 --- a/drivers/net/ethernet/intel/ice/ice_switch.c +++ b/drivers/net/ethernet/intel/ice/ice_switch.c @@ -5420,7 +5420,7 @@ ice_add_adv_recipe(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups, */ status = ice_add_special_words(rinfo, lkup_exts, ice_is_dvm_ena(hw)); if (status) - goto err_free_lkup_exts; + goto err_unroll; /* Group match words into recipes using preferred recipe grouping * criteria.