Message ID | 1412253679-12390-1-git-send-email-maxim.uvarov@linaro.org |
---|---|
State | Superseded |
Headers | show |
Can you put the coverity id in the patch description ? On 2 October 2014 08:41, Maxim Uvarov <maxim.uvarov@linaro.org> wrote: > Fix Coverity warnings about resource leaks. > > Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> > --- > 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; > } > > -- > 1.8.5.1.163.gd7aced9 > > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > http://lists.linaro.org/mailman/listinfo/lng-odp >
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; }
Fix Coverity warnings about resource leaks. Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> --- 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(-)