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 C6479460AC; Fri, 17 Jan 2025 18:52:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6090C40B8D; Fri, 17 Jan 2025 18:52:15 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) by mails.dpdk.org (Postfix) with ESMTP id AAD0F40294; Fri, 17 Jan 2025 18:52:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1737136334; x=1768672334; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=o6zZaDnoBOY4Lk1Vj7kVPL5bTQWOJhqfBxGJQ4LUVPo=; b=fS54aumdAJD6fj/gZDYT8mEGXL0gAlYh56DuXd76Ouzh22SlINP98ZmR +l2Uz5luwt5D9uCLdKZh7Il9f7P5IK0K8lnX2Otr+rcZG5Za6tzBuYaya FABt7ISEQx5H9PjHWAn2dWUDa5S3lv0699dIDgjdY4ADNKdVgbJsOwyBG 6YYTdFEdSnUU6ZG1mDSzALWnuSQhqbd6rjve78ZF9IoxRK4hvwZa6Lg/G SF5YjcaeqPkqarf4lBD4OagM4wSDvujDhV7qDi+qUYccnFMUERJghM40/ llh6Xka9c2yS974zHway7N/aDCiLx5hrZ2/qE+lbRUV5S7L2Gj/44qhr5 A==; X-CSE-ConnectionGUID: A+8apPCtQLem3B+iNDXhDg== X-CSE-MsgGUID: JA7mV1P8Tvyabydg6JLsjQ== X-IronPort-AV: E=McAfee;i="6700,10204,11318"; a="37813090" X-IronPort-AV: E=Sophos;i="6.13,212,1732608000"; d="scan'208";a="37813090" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2025 09:52:13 -0800 X-CSE-ConnectionGUID: KdKbBPDsQVOOsbR64kSAwg== X-CSE-MsgGUID: X8AuBWv9S8unIzNyueiPqQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,212,1732608000"; d="scan'208";a="136694284" Received: from unknown (HELO silpixa00401176.ir.intel.com) ([10.243.23.51]) by orviesa002.jf.intel.com with ESMTP; 17 Jan 2025 09:52:11 -0800 From: Vladimir Medvedkin To: dev@dpdk.org Cc: anatoly.burakov@intel.com, bruce.richardson@intel.com, yuanx.wang@intel.com, stable@dpdk.org Subject: [PATCH] net/ice: fix memory leak in scalar Rx Date: Fri, 17 Jan 2025 17:52:05 +0000 Message-ID: <20250117175205.1598739-1-vladimir.medvedkin@intel.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org If the buffer splitting feature is configured and the payload mbuf allocation fails, the previously allocated header mbuf may be returned not fully initialized or a memory leak may occur. This patch handles this case correctly by freeing the corresponding header buffer. Fixes: 629dad3ef325 ("net/ice: support buffer split in scalar Rx") Cc: yuanx.wang@intel.com Cc: stable@dpdk.org Signed-off-by: Vladimir Medvedkin --- drivers/net/ice/ice_rxtx.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index 0c7106c7e0..f58df9bdfe 100644 --- a/drivers/net/ice/ice_rxtx.c +++ b/drivers/net/ice/ice_rxtx.c @@ -484,6 +484,7 @@ ice_alloc_rx_queue_mbufs(struct ice_rx_queue *rxq) struct rte_mbuf *mbuf_pay; mbuf_pay = rte_mbuf_raw_alloc(rxq->rxseg[1].mp); if (unlikely(!mbuf_pay)) { + rte_pktmbuf_free(mbuf); PMD_DRV_LOG(ERR, "Failed to allocate payload mbuf for RX"); return -ENOMEM; } @@ -1900,6 +1901,8 @@ ice_rx_alloc_bufs(struct ice_rx_queue *rxq) diag_pay = rte_mempool_get_bulk(rxq->rxseg[1].mp, (void *)mbufs_pay, rxq->rx_free_thresh); if (unlikely(diag_pay != 0)) { + rte_mempool_put_bulk(rxq->mp, (void *)rxep, + rxq->rx_free_thresh); PMD_RX_LOG(ERR, "Failed to get payload mbufs in bulk"); return -ENOMEM; } @@ -2607,6 +2610,13 @@ ice_recv_pkts(void *rx_queue, nmb_pay = rte_mbuf_raw_alloc(rxq->rxseg[1].mp); if (unlikely(!nmb_pay)) { rxq->vsi->adapter->pf.dev_data->rx_mbuf_alloc_failed++; + rxe->mbuf = NULL; + nb_hold--; + if (unlikely(rx_id == 0)) + rx_id = rxq->nb_rx_desc; + + rx_id--; + rte_pktmbuf_free(nmb); break; } -- 2.43.0