Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3822024pxm; Tue, 1 Mar 2022 06:09:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/nIoxbpCc2O62L68eH/NWVOal4okSj25SU5MWVGLtBxhr2kSBnqzeLpNSobY2pc0cmDwI X-Received: by 2002:a17:906:66cb:b0:6cf:e4f7:9504 with SMTP id k11-20020a17090666cb00b006cfe4f79504mr19302678ejp.142.1646143760827; Tue, 01 Mar 2022 06:09:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646143760; cv=none; d=google.com; s=arc-20160816; b=E8lfRWcoEqTEClDpUPYyxfqd+USPWs1x/ZSBbjxZP1Faod9QikkoE7YWQDWFw38bK7 dXTV/61Qfw/0W4LQyfPJQb15KxJhSSpvtBT8obLAYZce79N+G/uBNmw8Ne/B3RKevIwr YdTo5o+c2EpLFjeBJVrhrh0Cv8tB6pu35w9JBl24+gt9uo5vDYaEfnZWyHwZHWcYhYAi 9XsDjBR0NiITpHPE4280WT1+PbdKnosv+kVNo1SwGIvg0MjB/qLQnuYiI+bE/VlQOFGU D4hqtb4L0h4tAjAM360hex5X8n1mUp2Ul+s+QY+WlgSib6XGHcia71kqBKVUAjQJWO0k zUxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=dpPfXCVIVic4IO/yNFowNfq6++iUgC1vjMlrqF3PzrY=; b=FAT0CmjlLCKp3r1tCzLlGG+3xiMbqwhBsfA47YLSasHLaeMHQ2rW9of/Cn1S7qEIZ/ w3raFSgjD4FTZI2iyiVEvNkjTmTU2CdZKUOzUv+21jn2gryrV0icamG1fcjbRIbVlKvg pr5yXNow8jS9vvvXVbZeQeNXHU2G6wP+3UVjVv//B8OryQ5ZgBQLEADcVxGo/l7PVR0n MkJRogXPWZ8Z0/U2HQnuBmkrWoEE+TNbsXLz4o9eigDxPvA7wHj4VKgE8I/H7bBh9mF7 hQjqqcSPLmsLrpR5c/4rfvmcJD232OlshG9OgTXzaNMFGUnZLVtfBHAgrMKnQ88hB/tf IEiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NTyQV3hn; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bk19-20020a170906b0d300b006cb4fa23664si8201292ejb.880.2022.03.01.06.08.52; Tue, 01 Mar 2022 06:09:20 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NTyQV3hn; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233726AbiCAJ0s (ORCPT + 99 others); Tue, 1 Mar 2022 04:26:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbiCAJ0r (ORCPT ); Tue, 1 Mar 2022 04:26:47 -0500 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3663C6B098; Tue, 1 Mar 2022 01:26:07 -0800 (PST) Received: by mail-pg1-x529.google.com with SMTP id w37so13941938pga.7; Tue, 01 Mar 2022 01:26:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dpPfXCVIVic4IO/yNFowNfq6++iUgC1vjMlrqF3PzrY=; b=NTyQV3hnVA2m/a5GnW4m+f2vzbBMkM7OJONvGAM0Ixg5j51lwtu0kffCQDwWEtuByo dZQZpLdcH3dn3TBdUc/r00+YxTy/1vZ7Fv2u7vWRElxECLUoS/CsC29AU8nd3G6D5+to Lf6s6RIs6l/MzaE/WEOfbpy6+dekYeNRFdxsN4U5lm/HiplOw0x+h77sXwJmx2zce/cK NSwm/H3kp8Kkoc/zpaRkb5q9SAj3P+uaoaTEuw8TqPyJzzoS1BP0pQbOM44Ap3rj4gvi bjpOYtPcJ7/kY0A6OWGWm315OjueshDlA1cVgyElWzKVG5YgZKuU3QkC4TQUqU61aDnp yUJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dpPfXCVIVic4IO/yNFowNfq6++iUgC1vjMlrqF3PzrY=; b=ZDe5g1CFfsNc5zi3wFrgs1STTwPA8Fvf1LovSkm8u4IyE3f0TRSiRxBXYyOa4ZPM7o MtYhyAMesfKqPl7Eb8/2vzDhWeXniGq9fl5gJqN377RxsUZsUUG2LszNy17CQKKmi9+r Hx0DMY73O8tBjf5Q8exJjbzwk844AxS2znytNH+W2jGOD5TTxCfR2bVH9hRSbRBsAf/1 D1D5WyFc1NiuXFF3OZo2RoiO9MWdsw63+EtAALjnws/TnLuVrPvFYMFhhcUzmmoW6Ras LSo4dR3oiAfiJmiSQjlCiDyikIjRyI1Ln1vGRnaVdrxsd1iGVmDPJAZSSzbGzLlwt3L+ rmnQ== X-Gm-Message-State: AOAM530giBQIDoaBsBNd3BX6JWpUc2HHUddNEzpREVfP5vlJuqffDvtY 6ZFk5OldnQ0YN8z21fsD/Ug= X-Received: by 2002:a65:6803:0:b0:378:9366:3849 with SMTP id l3-20020a656803000000b0037893663849mr8437562pgt.484.1646126766624; Tue, 01 Mar 2022 01:26:06 -0800 (PST) Received: from localhost.localdomain ([115.27.208.93]) by smtp.gmail.com with ESMTPSA id q13-20020a056a00088d00b004e1bea9c582sm16570408pfj.43.2022.03.01.01.26.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Mar 2022 01:26:06 -0800 (PST) From: Q1IQ To: ioana.ciornei@nxp.com, davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, lyz_cs@pku.edu.cn, Q1IQ Subject: [PATCH] dpaa2 ethernet switch driver: Fix memory leak in dpaa2_switch_acl_entry_remove() Date: Tue, 1 Mar 2022 17:24:50 +0800 Message-Id: <20220301092450.42523-1-fufuyqqqqqq@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HK_RANDOM_ENVFROM, HK_RANDOM_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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 [why] The error handling branch did not properly free the memory of cmd_buf before return, which would cause memory leak. [how] Fix this by adding kfree to the error handling branch. Signed-off-by: Q1IQ --- drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-flower.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-flower.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-flower.c index cacd454ac696..e85ca01718a9 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-flower.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-flower.c @@ -172,6 +172,7 @@ dpaa2_switch_acl_entry_remove(struct dpaa2_switch_filter_block *block, DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, acl_entry_cfg->key_iova))) { dev_err(dev, "DMA mapping failed\n"); + kfree(cmd_buff); return -EFAULT; } @@ -182,6 +183,7 @@ dpaa2_switch_acl_entry_remove(struct dpaa2_switch_filter_block *block, DMA_TO_DEVICE); if (err) { dev_err(dev, "dpsw_acl_remove_entry() failed %d\n", err); + kfree(cmd_buff); return err; } -- 2.30.1 (Apple Git-130)