From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 444E17CC4 for ; Wed, 18 Apr 2018 18:58:19 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Apr 2018 09:58:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,466,1517904000"; d="scan'208";a="34637334" Received: from sivswdev02.ir.intel.com (HELO localhost.localdomain) ([10.237.217.46]) by orsmga008.jf.intel.com with ESMTP; 18 Apr 2018 09:58:17 -0700 From: Reshma Pattan To: dev@dpdk.org Cc: jasvinder.singh@intel.com, Reshma Pattan Date: Wed, 18 Apr 2018 17:58:09 +0100 Message-Id: <1524070690-12000-3-git-send-email-reshma.pattan@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1524070690-12000-1-git-send-email-reshma.pattan@intel.com> References: <1524070690-12000-1-git-send-email-reshma.pattan@intel.com> Subject: [dpdk-dev] [PATCH] examples/ip_pipipeline: fix resource leak 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: Wed, 18 Apr 2018 16:58:19 -0000 Close tap device fd before returning upon failures. Coverity issue: 272576 Fixes: 2f74ae28e2 ("examples/ip_pipeline: add tap object") CC: jasvinder.singh@intel.com Signed-off-by: Reshma Pattan --- examples/ip_pipeline/tap.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/ip_pipeline/tap.c b/examples/ip_pipeline/tap.c index 5b3403218..a0f60867f 100644 --- a/examples/ip_pipeline/tap.c +++ b/examples/ip_pipeline/tap.c @@ -76,14 +76,17 @@ tap_create(const char *name) snprintf(ifr.ifr_name, IFNAMSIZ, "%s", name); status = ioctl(fd, TUNSETIFF, (void *) &ifr); - if (status < 0) + if (status < 0) { + close(fd); return NULL; + } /* Node allocation */ tap = calloc(1, sizeof(struct tap)); - if (tap == NULL) + if (tap == NULL) { + close(fd); return NULL; - + } /* Node fill in */ strncpy(tap->name, name, sizeof(tap->name)); tap->fd = fd; -- 2.14.3