From patchwork Thu Oct 2 12:41:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 38294 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f70.google.com (mail-ee0-f70.google.com [74.125.83.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 327C220549 for ; Thu, 2 Oct 2014 12:41:51 +0000 (UTC) Received: by mail-ee0-f70.google.com with SMTP id c13sf1117279eek.9 for ; Thu, 02 Oct 2014 05:41:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=Qa7eHGLkY7UyrE1YVy6GePBH02MvMSn7b+sTKMqXACU=; b=P+0myoLiWsIuo+eOoP9qbCpFyClpus8G9KLO5ZfRtW3qqW8uDmR4zr/54TRSpjAbBQ ZZ2HUxWI5o42WvBvQSOeyhneOomkoET4gfkWst+YAjdmqCYmA+SOv7jcr7+Y4K9hIdiu tLVlSlqOC62z93XjJ9w44zlIaV59omtnDYXuVSRlxkg6pkWO36nJLVy32MjewBsbJHlc vOebiD61HFsML5+IrBFSSAZ73T/LN0RWwFL1gnqo9Vqwdpujg1tgfrRMVfN39oaCOn3N W1aYYupk3X0Ndi8TF3wb0sLdqeBurVrh5GytefCArcsVU4i49PhZ3ODeCCY2BXLjuGLz q+LQ== X-Gm-Message-State: ALoCoQlVTjMokG9F+jfzArPP9ISNvxEjxxBndsvj3gfzietl1v397SfjyrxlltgGVio9rN2+wALc X-Received: by 10.152.42.229 with SMTP id r5mr845367lal.8.1412253710296; Thu, 02 Oct 2014 05:41:50 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.26.73 with SMTP id j9ls284026lag.29.gmail; Thu, 02 Oct 2014 05:41:50 -0700 (PDT) X-Received: by 10.112.54.130 with SMTP id j2mr29200961lbp.41.1412253710065; Thu, 02 Oct 2014 05:41:50 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com [209.85.217.171]) by mx.google.com with ESMTPS id tl10si6304288lbb.131.2014.10.02.05.41.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 02 Oct 2014 05:41:49 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by mail-lb0-f171.google.com with SMTP id z12so2192806lbi.16 for ; Thu, 02 Oct 2014 05:41:49 -0700 (PDT) X-Received: by 10.152.204.231 with SMTP id lb7mr61766427lac.44.1412253709789; Thu, 02 Oct 2014 05:41:49 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.130.169 with SMTP id of9csp44546lbb; Thu, 2 Oct 2014 05:41:49 -0700 (PDT) X-Received: by 10.140.41.9 with SMTP id y9mr2700368qgy.62.1412253708642; Thu, 02 Oct 2014 05:41:48 -0700 (PDT) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id q5si7162753qat.17.2014.10.02.05.41.45 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 02 Oct 2014 05:41:48 -0700 (PDT) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XZfhY-0004BJ-4y; Thu, 02 Oct 2014 12:41:44 +0000 Received: from mail-la0-f41.google.com ([209.85.215.41]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XZfhR-0004BE-D5 for lng-odp@lists.linaro.org; Thu, 02 Oct 2014 12:41:37 +0000 Received: by mail-la0-f41.google.com with SMTP id pn19so2288441lab.0 for ; Thu, 02 Oct 2014 05:41:31 -0700 (PDT) X-Received: by 10.112.185.68 with SMTP id fa4mr3944121lbc.77.1412253691428; Thu, 02 Oct 2014 05:41:31 -0700 (PDT) Received: from localhost.localdomain (ppp79-139-142-244.pppoe.spdop.ru. [79.139.142.244]) by mx.google.com with ESMTPSA id x5sm1552513lad.30.2014.10.02.05.41.29 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 02 Oct 2014 05:41:30 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 2 Oct 2014 16:41:19 +0400 Message-Id: <1412253679-12390-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 X-Topics: patch Subject: [lng-odp] [PATCH] resource leak fixes X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: maxim.uvarov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Fix Coverity warnings about resource leaks. Signed-off-by: Maxim Uvarov --- example/ipsec/odp_ipsec.c | 1 + platform/linux-generic/odp_packet_socket.c | 1 + test/api_test/odp_ring_test.c | 5 ++++- test/api_test/odp_timer_ping.c | 4 ++-- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index cd94d9a..b7544ce 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -243,6 +243,7 @@ int query_mac_address(char *intf, uint8_t *src_mac) memset(&ifr, 0, sizeof(ifr)); snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", intf); if (ioctl(sd, SIOCGIFHWADDR, &ifr) < 0) { + close(sd); ODP_ERR("Error: ioctl() failed for %s\n", intf); return -1; } diff --git a/platform/linux-generic/odp_packet_socket.c b/platform/linux-generic/odp_packet_socket.c index e173c31..d0fb10e 100644 --- a/platform/linux-generic/odp_packet_socket.c +++ b/platform/linux-generic/odp_packet_socket.c @@ -504,6 +504,7 @@ static int mmap_pkt_socket(void) ret = setsockopt(sock, SOL_PACKET, PACKET_VERSION, &ver, sizeof(ver)); if (ret == -1) { + close(sock); perror("pkt_socket() - setsockopt(PACKET_VERSION)"); return -1; } diff --git a/test/api_test/odp_ring_test.c b/test/api_test/odp_ring_test.c index d75c30b..1da5845 100644 --- a/test/api_test/odp_ring_test.c +++ b/test/api_test/odp_ring_test.c @@ -261,8 +261,10 @@ static int producer_fn(void) do { i = odph_ring_mp_enqueue_bulk(r_stress, src, MAX_BULK); - if (i == 0) + if (i == 0) { + free(src); return 0; + } } while (1); } @@ -288,6 +290,7 @@ static int consumer_fn(void) return -1; } } + free(src); printf("\n Test OK !\n"); return 0; } diff --git a/test/api_test/odp_timer_ping.c b/test/api_test/odp_timer_ping.c index 7406a45..65e3834 100644 --- a/test/api_test/odp_timer_ping.c +++ b/test/api_test/odp_timer_ping.c @@ -167,8 +167,7 @@ static int send_ping_request(struct sockaddr_in *addr) sd = socket(PF_INET, SOCK_RAW, proto->p_proto); if (sd < 0) { ODP_ERR("Sender socket open failed\n"); - err = -1; - goto err; + return -1; } if (setsockopt(sd, SOL_IP, IP_TTL, &val, sizeof(val)) != 0) { @@ -240,6 +239,7 @@ static int send_ping_request(struct sockaddr_in *addr) } err: + close(sd); return err; }