From patchwork Thu Oct 2 13:57:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 38297 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 16AC420549 for ; Thu, 2 Oct 2014 13:58:21 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gq15sf1216794lab.11 for ; Thu, 02 Oct 2014 06:58:20 -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=ZqIrtjv8U3oUtB9RbFj87ti5iUvvZlQcvTvXQKeekoc=; b=ESgu8ilhgDDFhotS2FeU+x6rZHPQJLGgy2IKJcoO6JAvsdTO28Hp1iUJ6+D4/PcRVp niII0hiSAqXU5zq273UfFQwyx54syte6OB7DSLMc3LDTlQUTt5wCIeoxNSxLX4/T7MxE WKSZCSxdXyLNQ9vni5/ZbvprNrGDW32Kg4zDtMBhdCb6O6sFcQWNphRriIC19ELdYv3w 64a69UQOR/u/hvRbwyviAIJYNuuPNl0FEHkz/GXwS2Xz0y/LU9H/ul89UoPSKS/f/67y e+RaF+19oSCObdooHeq2uwvZyu3WtXQowVzF7Hp/Y9OgsA4RJWDGngU+FLf6cJScQ0bF i5MQ== X-Gm-Message-State: ALoCoQl7n9sF7psYgDERQkzLqfu6yOayXtIDos1576CUrpwiyBnSOHuosK4zgdyizSSPqgF1mkxE X-Received: by 10.194.7.199 with SMTP id l7mr48777wja.2.1412258300909; Thu, 02 Oct 2014 06:58:20 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.9.226 with SMTP id d2ls265271lab.66.gmail; Thu, 02 Oct 2014 06:58:20 -0700 (PDT) X-Received: by 10.152.1.137 with SMTP id 9mr33660684lam.85.1412258300653; Thu, 02 Oct 2014 06:58:20 -0700 (PDT) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com [209.85.217.180]) by mx.google.com with ESMTPS id rs4si3321067lbb.12.2014.10.02.06.58.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 02 Oct 2014 06:58:20 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by mail-lb0-f180.google.com with SMTP id f15so2305288lbj.11 for ; Thu, 02 Oct 2014 06:58:20 -0700 (PDT) X-Received: by 10.112.75.233 with SMTP id f9mr25414506lbw.102.1412258300510; Thu, 02 Oct 2014 06:58:20 -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 of9csp57506lbb; Thu, 2 Oct 2014 06:58:19 -0700 (PDT) X-Received: by 10.224.80.10 with SMTP id r10mr63755966qak.24.1412258299386; Thu, 02 Oct 2014 06:58:19 -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 w8si7526495qag.4.2014.10.02.06.58.18 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 02 Oct 2014 06:58:19 -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 1XZgtd-0006lg-KO; Thu, 02 Oct 2014 13:58:17 +0000 Received: from mail-lb0-f182.google.com ([209.85.217.182]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XZgtY-0006l8-2p for lng-odp@lists.linaro.org; Thu, 02 Oct 2014 13:58:12 +0000 Received: by mail-lb0-f182.google.com with SMTP id z11so2297150lbi.27 for ; Thu, 02 Oct 2014 06:58:06 -0700 (PDT) X-Received: by 10.152.5.9 with SMTP id o9mr27621657lao.95.1412258286140; Thu, 02 Oct 2014 06:58:06 -0700 (PDT) Received: from localhost.localdomain ([81.200.0.212]) by mx.google.com with ESMTPSA id l13sm1616267lbh.32.2014.10.02.06.58.04 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 02 Oct 2014 06:58:04 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 2 Oct 2014 17:57:57 +0400 Message-Id: <1412258277-13901-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] [PATCHv2] 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.180 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. Coverity CIDs: 56713, 5611, 56707, 56705, 56703. Signed-off-by: Maxim Uvarov Reviewed-by: Mike Holmes --- 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; }