From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 838651B720 for ; Thu, 8 Feb 2018 15:21:09 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id DB6B920D75; Thu, 8 Feb 2018 09:21:06 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Thu, 08 Feb 2018 09:21:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux.org; h=cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=ValsQCIxZLk64bwryJFbBdO9cXjzLkz6UmLb165+Bhg=; b=uHm7WVaa j0AgsneK3Iieu1HOxsUZbGBYklFQRz3yasKG2Abt20ZTCm1UCy5nFp060N1WCAMZ XF9t4J8ALxYYeItPl6odsJPe745Uz8oHikcOgyP9vD/xHY0+sYigIA7CYGwsjJg6 cud8jpds99DTHC/w+UbDHGaIIke72tgt9cAf72eP/RqjYPndmEBtqgl+7NgM2/+p fVy/7qqQ1PuxCuFWFUjW6UPfV8oqJ9kyxJ3xSu3UKUAF/dqJ3eGOwczBjEP3eUh3 FQs4/vxVb4kLbLyUpwpuTDtkp3aT0LPwsuZ/L1g4LErYfYhjGPQRzB9lXwgjH65N ZY7qx6g8oZxP9g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=ValsQCIxZLk64bwryJFbBdO9cXjzL kz6UmLb165+Bhg=; b=JLPBYmc1eTDMKetw7XzSoqFJQut+5zvkxRxclQmZOEdwe sOWnrBrsN+Ff3OwxPzZFtpw2/WzAcaERM0oY1SlOfiuwVEttGgbHjuPiMq8mQ0dO mhWB3iKP0nqLLPimZzypjNaOTjEfyF5IuO/VEB8feJhD00X/NSOzh9nQVuNfqrXe OjyixVBv/qgaUfx7zUBmGEmHQo9jzpT1Me1X1g/0tqompfAp4IoPPWt0eJ+vmyY5 SWd9/BXi0SewAmC5qhxtH/3N5AL2PJi8SBJYTK2v37cNEnoQUnQr5V/GeTfxhS6x G+26i3aRpdYn5qIPuhaOyMC2amQTalBIqH6YEHBnA== X-ME-Sender: Received: from yliu-mob (unknown [182.84.161.100]) by mail.messagingengine.com (Postfix) with ESMTPA id B11377E566; Thu, 8 Feb 2018 09:21:05 -0500 (EST) Date: Thu, 8 Feb 2018 22:21:01 +0800 From: Yuanhan Liu To: Yong Wang Cc: stable@dpdk.org Message-ID: <20180208142101.GA23970@yliu-mob> References: <1518088644-7214-1-git-send-email-wang.yong19@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1518088644-7214-1-git-send-email-wang.yong19@zte.com.cn> User-Agent: Mutt/1.5.24 (2015-08-30) Subject: Re: [dpdk-stable] [PATCH] net/dpaa: fix potential memory leak X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Feb 2018 14:21:09 -0000 On Thu, Feb 08, 2018 at 06:17:24AM -0500, Yong Wang wrote: > [ backported from upstream commit 0ff76833f8b54d61c2795d1710fb60aa499469bf ] > > There are several func calls to rte_zmalloc() which don't do null > pointer check on the return value. And before return, the memory is not > freed. Fix it by adding null pointer check and rte_free(). > > Fixes: 37f9b54bd3cf ("net/dpaa: support Tx and Rx queue setup") > Fixes: 62f53995caaf ("net/dpaa: add frame count based tail drop with CGR") > Cc: stable@dpdk.org > > Signed-off-by: Yong Wang > Reviewed-by: Shreyansh Jain Applied to dpdk-stable/17.11. Thanks! --yliu > --- > drivers/net/dpaa/dpaa_ethdev.c | 36 +++++++++++++++++++++++++----------- > 1 file changed, 25 insertions(+), 11 deletions(-) > > diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c > index 29678c5..e4375c3 100644 > --- a/drivers/net/dpaa/dpaa_ethdev.c > +++ b/drivers/net/dpaa/dpaa_ethdev.c > @@ -873,12 +873,17 @@ static int dpaa_debug_queue_init(struct qman_fq *fq, uint32_t fqid) > > dpaa_intf->rx_queues = rte_zmalloc(NULL, > sizeof(struct qman_fq) * num_rx_fqs, MAX_CACHELINE); > + if (!dpaa_intf->rx_queues) { > + DPAA_PMD_ERR("Failed to alloc mem for RX queues\n"); > + return -ENOMEM; > + } > + > for (loop = 0; loop < num_rx_fqs; loop++) { > fqid = DPAA_PCD_FQID_START + dpaa_intf->ifid * > DPAA_PCD_FQID_MULTIPLIER + loop; > ret = dpaa_rx_queue_init(&dpaa_intf->rx_queues[loop], fqid); > if (ret) > - return ret; > + goto free_rx; > dpaa_intf->rx_queues[loop].dpaa_intf = dpaa_intf; > } > dpaa_intf->nb_rx_queues = num_rx_fqs; > @@ -887,14 +892,17 @@ static int dpaa_debug_queue_init(struct qman_fq *fq, uint32_t fqid) > num_cores = rte_lcore_count(); > dpaa_intf->tx_queues = rte_zmalloc(NULL, sizeof(struct qman_fq) * > num_cores, MAX_CACHELINE); > - if (!dpaa_intf->tx_queues) > - return -ENOMEM; > + if (!dpaa_intf->tx_queues) { > + DPAA_PMD_ERR("Failed to alloc mem for TX queues\n"); > + ret = -ENOMEM; > + goto free_rx; > + } > > for (loop = 0; loop < num_cores; loop++) { > ret = dpaa_tx_queue_init(&dpaa_intf->tx_queues[loop], > fman_intf); > if (ret) > - return ret; > + goto free_tx; > dpaa_intf->tx_queues[loop].dpaa_intf = dpaa_intf; > } > dpaa_intf->nb_tx_queues = num_cores; > @@ -931,13 +939,8 @@ static int dpaa_debug_queue_init(struct qman_fq *fq, uint32_t fqid) > DPAA_PMD_ERR("Failed to allocate %d bytes needed to " > "store MAC addresses", > ETHER_ADDR_LEN * DPAA_MAX_MAC_FILTER); > - rte_free(dpaa_intf->rx_queues); > - rte_free(dpaa_intf->tx_queues); > - dpaa_intf->rx_queues = NULL; > - dpaa_intf->tx_queues = NULL; > - dpaa_intf->nb_rx_queues = 0; > - dpaa_intf->nb_tx_queues = 0; > - return -ENOMEM; > + ret = -ENOMEM; > + goto free_tx; > } > > /* copy the primary mac address */ > @@ -963,6 +966,17 @@ static int dpaa_debug_queue_init(struct qman_fq *fq, uint32_t fqid) > fman_if_stats_reset(fman_intf); > > return 0; > + > +free_tx: > + rte_free(dpaa_intf->tx_queues); > + dpaa_intf->tx_queues = NULL; > + dpaa_intf->nb_tx_queues = 0; > + > +free_rx: > + rte_free(dpaa_intf->rx_queues); > + dpaa_intf->rx_queues = NULL; > + dpaa_intf->nb_rx_queues = 0; > + return ret; > } > > static int > -- > 1.8.3.1