From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BFE27A0544 for ; Thu, 22 Sep 2022 15:10:06 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BA096427F0; Thu, 22 Sep 2022 15:10:06 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2136.outbound.protection.outlook.com [40.107.220.136]) by mails.dpdk.org (Postfix) with ESMTP id B447B400D7; Thu, 22 Sep 2022 15:10:04 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A0I4rfat8v+SmfWAN5241auDvNqn1Z6hlRO/zsSniYiRPERVSMGeiMrFWrpq2lLlqSzxb3ZOcqd2aHbcEK6R1QIHRc7Iy4AFnUXZSRQIKOhRc5F2M6hZhOg7f0AOkgrlCpXF7l6nApaPVEenIirrBvl5EVVd7fzpHZaFWH/rtFoDbDRuXCmuJ970G3IGOzc2JGYaqCzkEV6oScmo3bonz7+EWst4CJQJerBWCTlDWzJmaEz2G4AwuDUJBIs70ukUMb9rwRcm3fPr+JLxiTMf8VEurZgPFbToIAWrGrLoL9G/lwouXtuc15Df2PkPuowMBC+lkMchx7gntQpGSP1GWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zoVSskfYebDKpbfXVee9XG7CZbYy2aFXJnL9dBEkc7o=; b=G3+hHicO2PrlEnjNN4BSYjuPmE622oKsuUZ+a+z43NxWA6m26Sm2Pvz9Kk0NVcDL/Sou0HIPnnYVmL5oXOgkPqVuRoIkq8Ps1xCiXlPgxmjdXoE3RYTBLvPIfMGiEjOMV9XGZyQ5sV/4vfK2H4IWG25mamICQBJCzVf55M5AgK3UbBq6egfse/RMrXXnrsklxH9+fr0/AMVNwd0bRrPB2tLTK+8cEI6xGS154a+kapu0/Pei0dKW5sEC/Dqcm2fvg3ee4KH3PCp2qB3jkg1aXeBfqgriNj+aSgPneCPE1wT3REXMffo9xiMc80DLPMTYa6wff+BX2C0Se9EkRC+4FQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zoVSskfYebDKpbfXVee9XG7CZbYy2aFXJnL9dBEkc7o=; b=J8ayLIdWP1D6TSGcWQ+VAjA89m94V6GeAv5MQKud51wVG6375Zn61y1qtrRagbVkH55F/voq5NReLjU3fx2SAeirgybxOZcG/eRpInNrGfdB3l88F32AQQcbv2yr9T0Qbgd0q3unqv1hrwDzISi/HMK/yLe9g2oeDc+ZrLueJuI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from DM6PR13MB4431.namprd13.prod.outlook.com (2603:10b6:5:1bb::21) by PH7PR13MB5527.namprd13.prod.outlook.com (2603:10b6:510:139::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.14; Thu, 22 Sep 2022 13:10:01 +0000 Received: from DM6PR13MB4431.namprd13.prod.outlook.com ([fe80::e198:fd7c:5eb4:89c1]) by DM6PR13MB4431.namprd13.prod.outlook.com ([fe80::e198:fd7c:5eb4:89c1%5]) with mapi id 15.20.5654.014; Thu, 22 Sep 2022 13:10:01 +0000 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= To: dev@dpdk.org Cc: oss-drivers@corigine.com, Long Wu , louis.peens@corigine.com, stable@dpdk.org, Chaoyong He , =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH] net/nfp: fix memory leak for receive function Date: Thu, 22 Sep 2022 15:09:44 +0200 Message-Id: <20220922130944.698880-1-niklas.soderlund@corigine.com> X-Mailer: git-send-email 2.37.3 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: FR3P281CA0161.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::20) To DM6PR13MB4431.namprd13.prod.outlook.com (2603:10b6:5:1bb::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR13MB4431:EE_|PH7PR13MB5527:EE_ X-MS-Office365-Filtering-Correlation-Id: 44e69a89-93d2-4693-dd4d-08da9c9bc1ff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F7ppip2h8sv1zdb4q2WW03cyL0+nffon6MTO9yYYq7C5IeSBmaxg6f/dbVsu8UHJ2+TDkOOMXo6V4TRwcJVh77qMEE8rModLpWmlH7GVjyinylMLd9JCifcvpWCyy2ylOCvm0QUa1eaI6OyGjYzRa8afrlLJHV5hbCj8VfhD++1E+aMSBDJG2NtzdAIa2ETo2NRcLqTDHfEH8c6nL0CoRDvXlqbK0j+uZ609R8fg9A/78sptNH2qLVg7w4QQt/AY+qTpXw7Z5XsVIKViS9qN5rX4wauIQaI2vTfL9wsgPqlYvcIEwjQepdCuBWqIX95jjwMzq1kZKzC0wgoEdbd3PqW3oxAScDBNJG6m8w8tlOksn1zKiJ7oyJQOeClP81K7qKyJB6AtXvR960GJq4X98ZcysdTVuKH1FKDQE1QmNG1VrJudwVAo1HdwycDWyL87xUXOlhcV3ug+vl8FyFdB3itbhiu/YUhkpFi0gUmIkmQASqzUv3Z7RFvkcvrHAESHx2gep0jEx/HHpoHMuxUKTFp5DtGYsnQJLK7ym8f0c1CKBFLBXunK/KlI03RQuzGaQ8FMNJOIa7B55QWgQu6qpnblwzk0FKGwLiKnst5gohUGgf86GhfO/Ly2pP8r2xRzuybGgJauT+0d8tVKn5Cx9s0a2+8RldhfoZDSJdKVJgUW6wBcPllOlGB0qPt4tfd2TmC+YF9dfBIg1LpLvELe9PyswxFh8NtDu+G9t7uJ8SLBD5soq+XpRbNFWwZxWDUiseiIteswRC1SskfQg/LQXmsWmkbzTlWx/dfrP23/kGAtbiwjJ+7Etwa5cdnCkyvA X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR13MB4431.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(376002)(136003)(366004)(396003)(39840400004)(346002)(451199015)(5660300002)(83380400001)(8936002)(478600001)(66556008)(6486002)(54906003)(6916009)(6506007)(66946007)(450100002)(41300700001)(8676002)(107886003)(36756003)(66476007)(52116002)(4326008)(86362001)(186003)(26005)(6666004)(316002)(38100700002)(38350700002)(6512007)(2616005)(1076003)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?NlVNTWRFakFmNUp3RjgvczYxWkNRcDdoQmJ6SUZuaHMvWkRmVDIvdlFVbkNl?= =?utf-8?B?WXBMenNnbHpHeFBnQVNjNkJTRG4vVVRRcFloaGs3Q2FsYTdKa0ZNeXdBUVJI?= =?utf-8?B?L3hWTWZtTEY1TnlSR0V2TVlqRnlVZ1pXejE5cUhubXRNelAzTlhxRDJ5ckli?= =?utf-8?B?S01MNUd0VU53V2Fpa0pCS1k0S3pUYlk5d0lBZnpXUUtIOXk3c0NCVGtwclBF?= =?utf-8?B?Um5EdUpvWGJ0Q2puc3hVT21jcGhQb2U3Y1luUm9EdkNnMC9BMW9JWm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vTklTWi9wQ2dzbHhVV1l0YzRtWDdIYWEzanF0NmtiV3VjTW1h?= =?utf-8?B?Z1ZzWVgrN0pKc0lWRUJ0QnE3MG5aSS8xVXlMdW1jZUJUd3ZHcUZvbERpSXhR?= =?utf-8?Q?6r1moKU4jDUYj/zA6vmyMaU=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 44e69a89-93d2-4693-dd4d-08da9c9bc1ff X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4431.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2022 13:10:01.5762 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MMrIzZO3yD2oe2kCM398PNIQ9e0NyJV0GWZ8pmKo5TIx/4TckUozmHWESi8NCc4Iib39i/4cp97ATgRmFFgWcUZqlfwMxz/JVtus4tD4oe8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB5527 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org From: Long Wu nfp_net_recv_pkts() should not return a value that less than 0 and the inappropriate return value in receive loop also causes the memory leak. Modify code to avoid return a value less than 0. Furthermore, When nfp_net_recv_pkts() break out from the receive loop because of packet problems, a rte_mbuf will not be freed and it will cause memory leak. Free the rte_mbuf before break out. Fixes: b812daadad0d ("nfp: add Rx and Tx") Cc: louis.peens@corigine.com Cc: stable@dpdk.org Signed-off-by: Long Wu Reviewed-by: Chaoyong He Reviewed-by: Niklas Söderlund Signed-off-by: Niklas Söderlund --- drivers/net/nfp/nfp_rxtx.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index 12db07c276f0..34493722f1a4 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -281,8 +281,9 @@ nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) struct rte_mbuf *new_mb; uint16_t nb_hold; uint64_t dma_addr; - int avail; + uint16_t avail; + avail = 0; rxq = rx_queue; if (unlikely(rxq == NULL)) { /* @@ -290,11 +291,10 @@ nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) * enabled. But the queue needs to be configured */ RTE_LOG_DP(ERR, PMD, "RX Bad queue\n"); - return -EINVAL; + return avail; } hw = rxq->hw; - avail = 0; nb_hold = 0; while (avail < nb_pkts) { @@ -360,7 +360,8 @@ nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) hw->rx_offset, rxq->mbuf_size - hw->rx_offset, mb->data_len); - return -EINVAL; + rte_pktmbuf_free(mb); + break; } /* Filling the received mbuf with packet info */ -- 2.37.3