From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-we0-f174.google.com (mail-we0-f174.google.com [74.125.82.174]) by dpdk.org (Postfix) with ESMTP id 4D7D6312 for ; Fri, 9 May 2014 15:16:03 +0200 (CEST) Received: by mail-we0-f174.google.com with SMTP id k48so3871894wev.5 for ; Fri, 09 May 2014 06:16:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=cUh06Ilh5l44RXjoiS+rZT1ugQUkn6iOIH0b26H4EqY=; b=m5IhVU/O7jM15G1g5pyjYlzzE8fxIag/lNC2ERGS+b2y15x+vVMy2MgzfUSfqwgVk6 ISYa0d7O68rDAtLC5lcAv2aSFfBbk3QRASJk1dpxbbH9rQ5iXTlTrvy45wvNjqXLQoaL NYtt2foKDO66nY8tPhh0gZPMNTpw+vD+X5qSC00STMxIU4RyXX/qMcq0JHWsHO071t0H enppmvKY4o2dXyhY4CGqN3jaVVHpnbSeANnMbwWYCIvoJzdGDeclM7Wqdb2xaI5EjE3o 48wOwab+7x7KfncQ0Hms3dqMsPrk8sGHQ8SW1JMYn9SaZBcFrcKwMd3BA8TEKtkw1qGr FigA== X-Gm-Message-State: ALoCoQljpYrq7up8uFxjkP1EH9/JJhx4ZmbrikjsDp+0PMAj2t0f4ew3ybjlXXNIFNJjOu6SU0iK X-Received: by 10.194.91.175 with SMTP id cf15mr8520444wjb.5.1399641369599; Fri, 09 May 2014 06:16:09 -0700 (PDT) Received: from alcyon.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id go1sm5086560wib.7.2014.05.09.06.16.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 May 2014 06:16:08 -0700 (PDT) From: David Marchand To: dev@dpdk.org Date: Fri, 9 May 2014 15:15:53 +0200 Message-Id: <1399641359-11267-2-git-send-email-david.marchand@6wind.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1399641359-11267-1-git-send-email-david.marchand@6wind.com> References: <1399641359-11267-1-git-send-email-david.marchand@6wind.com> Subject: [dpdk-dev] [PATCH v2 1/7] pci: fix potential mem leaks X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 May 2014 13:16:03 -0000 Looking at bsd implementation, we can see that there are some potential mem leaks in linux implementation. Fix them. Signed-off-by: David Marchand --- lib/librte_eal/linuxapp/eal/eal_pci.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c index 9538efe..99e07d2 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -649,11 +649,13 @@ pci_uio_map_resource(struct rte_pci_device *dev) memcpy(&uio_res->pci_addr, &dev->addr, sizeof(uio_res->pci_addr)); /* collect info about device mappings */ - if ((nb_maps = pci_uio_get_mappings(dirname, uio_res->maps, - sizeof (uio_res->maps) / sizeof (uio_res->maps[0]))) - < 0) + nb_maps = pci_uio_get_mappings(dirname, uio_res->maps, + RTE_DIM(uio_res->maps)); + if (nb_maps < 0) { + rte_free(uio_res); return (nb_maps); - + } + uio_res->nb_maps = nb_maps; /* Map all BARs */ @@ -678,6 +680,7 @@ pci_uio_map_resource(struct rte_pci_device *dev) (mapaddr = pci_map_resource(dev, NULL, devname, (off_t)offset, (size_t)maps[j].size)) == NULL) { + rte_free(uio_res); return (-1); } -- 1.7.10.4