From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by dpdk.org (Postfix) with ESMTP id 3F7081B53 for ; Sun, 22 Jul 2018 12:55:48 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A590E401EF05 for ; Sun, 22 Jul 2018 10:55:47 +0000 (UTC) Received: from dhcp-25.97.bos.redhat.com (ovpn-120-39.rdu2.redhat.com [10.10.120.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A04476CD for ; Sun, 22 Jul 2018 10:55:47 +0000 (UTC) From: Aaron Conole To: dev@dpdk.org Date: Sun, 22 Jul 2018 06:55:45 -0400 Message-Id: <20180722105545.3916-1-aconole@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Sun, 22 Jul 2018 10:55:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Sun, 22 Jul 2018 10:55:47 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'aconole@redhat.com' RCPT:'' Subject: [dpdk-dev] [PATCH] eal: free leaked logid storage X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Jul 2018 10:55:48 -0000 Previously, the logid variable would be leaked when the function returned. Signed-off-by: Aaron Conole --- lib/librte_eal/linuxapp/eal/eal.c | 65 ++++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 21 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c index d2d5aae80..3208e7079 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -833,7 +833,8 @@ rte_eal_init(int argc, char **argv) if (rte_eal_cpu_init() < 0) { rte_eal_init_alert("Cannot detect lcores."); rte_errno = ENOTSUP; - return -1; + fctret = -1; + goto finished; } fctret = eal_parse_args(argc, argv); @@ -841,27 +842,31 @@ rte_eal_init(int argc, char **argv) rte_eal_init_alert("Invalid 'command line' arguments."); rte_errno = EINVAL; rte_atomic32_clear(&run_once); - return -1; + fctret = -1; + goto finished; } if (eal_plugins_init() < 0) { rte_eal_init_alert("Cannot init plugins\n"); rte_errno = EINVAL; rte_atomic32_clear(&run_once); - return -1; + fctret = -1; + goto finished; } if (eal_option_device_parse()) { rte_errno = ENODEV; rte_atomic32_clear(&run_once); - return -1; + fctret = -1; + goto finished; } rte_config_init(); if (rte_eal_intr_init() < 0) { rte_eal_init_alert("Cannot init interrupt-handling thread\n"); - return -1; + fctret = -1; + goto finished; } /* Put mp channel init before bus scan so that we can init the vdev @@ -871,7 +876,8 @@ rte_eal_init(int argc, char **argv) rte_eal_init_alert("failed to init mp channel\n"); if (rte_eal_process_type() == RTE_PROC_PRIMARY) { rte_errno = EFAULT; - return -1; + fctret = -1; + goto finished; } } @@ -879,7 +885,8 @@ rte_eal_init(int argc, char **argv) rte_eal_init_alert("Cannot scan the buses for devices\n"); rte_errno = ENODEV; rte_atomic32_clear(&run_once); - return -1; + fctret = -1; + goto finished; } /* autodetect the iova mapping mode (default is iova_pa) */ @@ -903,7 +910,8 @@ rte_eal_init(int argc, char **argv) rte_eal_init_alert("Cannot get hugepage information."); rte_errno = EACCES; rte_atomic32_clear(&run_once); - return -1; + fctret = -1; + goto finished; } } @@ -929,7 +937,8 @@ rte_eal_init(int argc, char **argv) rte_eal_init_alert("Cannot init logging."); rte_errno = ENOMEM; rte_atomic32_clear(&run_once); - return -1; + fctret = -1; + goto finished; } #ifdef VFIO_PRESENT @@ -937,7 +946,8 @@ rte_eal_init(int argc, char **argv) rte_eal_init_alert("Cannot init VFIO\n"); rte_errno = EAGAIN; rte_atomic32_clear(&run_once); - return -1; + fctret = -1; + goto finished; } #endif /* in secondary processes, memory init may allocate additional fbarrays @@ -947,13 +957,15 @@ rte_eal_init(int argc, char **argv) if (rte_eal_memzone_init() < 0) { rte_eal_init_alert("Cannot init memzone\n"); rte_errno = ENODEV; - return -1; + fctret = -1; + goto finished; } if (rte_eal_memory_init() < 0) { rte_eal_init_alert("Cannot init memory\n"); rte_errno = ENOMEM; - return -1; + fctret = -1; + goto finished; } /* the directories are locked during eal_hugepage_info_init */ @@ -962,25 +974,29 @@ rte_eal_init(int argc, char **argv) if (rte_eal_malloc_heap_init() < 0) { rte_eal_init_alert("Cannot init malloc heap\n"); rte_errno = ENODEV; - return -1; + fctret = -1; + goto finished; } if (rte_eal_tailqs_init() < 0) { rte_eal_init_alert("Cannot init tail queues for objects\n"); rte_errno = EFAULT; - return -1; + fctret = -1; + goto finished; } if (rte_eal_alarm_init() < 0) { rte_eal_init_alert("Cannot init interrupt-handling thread\n"); /* rte_eal_alarm_init sets rte_errno on failure. */ - return -1; + fctret = -1; + goto finished; } if (rte_eal_timer_init() < 0) { rte_eal_init_alert("Cannot init HPET or TSC timers\n"); rte_errno = ENOTSUP; - return -1; + fctret = -1; + goto finished; } eal_check_mem_on_local_socket(); @@ -1034,20 +1050,24 @@ rte_eal_init(int argc, char **argv) if (ret) { rte_eal_init_alert("rte_service_init() failed\n"); rte_errno = ENOEXEC; - return -1; + fctret = -1; + goto finished; } /* Probe all the buses and devices/drivers on them */ if (rte_bus_probe()) { rte_eal_init_alert("Cannot probe devices\n"); rte_errno = ENOTSUP; - return -1; + fctret = -1; + goto finished; } #ifdef VFIO_PRESENT /* Register mp action after probe() so that we got enough info */ - if (rte_vfio_is_enabled("vfio") && vfio_mp_sync_setup() < 0) - return -1; + if (rte_vfio_is_enabled("vfio") && vfio_mp_sync_setup() < 0) { + fctret = -1; + goto finished; + } #endif /* initialize default service/lcore mappings and start running. Ignore @@ -1056,11 +1076,14 @@ rte_eal_init(int argc, char **argv) ret = rte_service_start_with_defaults(); if (ret < 0 && ret != -ENOTSUP) { rte_errno = ENOEXEC; - return -1; + fctret = -1; + goto finished; } rte_eal_mcfg_complete(); +finished: + free(logid); return fctret; } -- 2.14.3