From: Stefano Brivio <sbrivio@redhat.com>
To: passt-dev@passt.top
Subject: [PATCH 05/16] tap: Resource leak, CWE-404
Date: Tue, 05 Apr 2022 19:05:03 +0200 [thread overview]
Message-ID: <20220405170514.2963773-6-sbrivio@redhat.com> (raw)
In-Reply-To: <20220405170514.2963773-1-sbrivio@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 608 bytes --]
Reported by Coverity.
Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com>
---
tap.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tap.c b/tap.c
index e4dd804..8310891 100644
--- a/tap.c
+++ b/tap.c
@@ -899,8 +899,11 @@ static int tap_ns_tun(void *arg)
if (ns_enter(c) ||
(tun_ns_fd = open("/dev/net/tun", flags)) < 0 ||
ioctl(tun_ns_fd, TUNSETIFF, &ifr) ||
- !(c->pasta_ifi = if_nametoindex(c->pasta_ifn)))
+ !(c->pasta_ifi = if_nametoindex(c->pasta_ifn))) {
+ if (tun_ns_fd != -1)
+ close(tun_ns_fd);
tun_ns_fd = -1;
+ }
return 0;
}
--
@@ -899,8 +899,11 @@ static int tap_ns_tun(void *arg)
if (ns_enter(c) ||
(tun_ns_fd = open("/dev/net/tun", flags)) < 0 ||
ioctl(tun_ns_fd, TUNSETIFF, &ifr) ||
- !(c->pasta_ifi = if_nametoindex(c->pasta_ifn)))
+ !(c->pasta_ifi = if_nametoindex(c->pasta_ifn))) {
+ if (tun_ns_fd != -1)
+ close(tun_ns_fd);
tun_ns_fd = -1;
+ }
return 0;
}
--
2.35.1
next prev parent reply other threads:[~2022-04-05 17:05 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-05 17:04 [PATCH 00/16] Fix issues reported by Coverity Stefano Brivio
2022-04-05 17:04 ` [PATCH 01/16] treewide: Invalid type in argument to printf format specifier, CWE-686 Stefano Brivio
2022-04-05 17:05 ` [PATCH 02/16] passt: Ignoring number of bytes read, CWE-252 Stefano Brivio
2022-04-05 17:05 ` [PATCH 03/16] tcp: False "Untrusted loop bound" positive, CWE-606 Stefano Brivio
2022-04-05 17:05 ` [PATCH 04/16] treewide: Unchecked return value from library, CWE-252 Stefano Brivio
2022-04-05 17:05 ` Stefano Brivio [this message]
2022-04-05 17:05 ` [PATCH 06/16] conf, packet: Operands don't affect result, CWE-569 Stefano Brivio
2022-04-05 17:05 ` [PATCH 07/16] passt: Improper use of negative value (CWE-394) Stefano Brivio
2022-04-05 17:05 ` [PATCH 08/16] treewide: Argument cannot be negative, CWE-687 Stefano Brivio
2022-04-05 17:05 ` [PATCH 09/16] conf: False "Assign instead of compare" positive, CWE-481 Stefano Brivio
2022-04-05 17:05 ` [PATCH 10/16] conf, tap: False "Buffer not null terminated" positives, CWE-170 Stefano Brivio
2022-04-05 17:05 ` [PATCH 11/16] tcp: Dereference null return value, CWE-476 Stefano Brivio
2022-04-05 17:05 ` [PATCH 12/16] tcp_splice: Logically dead code, CWE-561 Stefano Brivio
2022-04-05 17:05 ` [PATCH 13/16] tcp, tcp_splice: False "Negative array index read" positives, CWE-129 Stefano Brivio
2022-04-05 17:05 ` [PATCH 14/16] tcp: False "Out-of-bounds read" positive, CWE-125 Stefano Brivio
2022-04-05 17:05 ` [PATCH 15/16] udp: Out-of-bounds read, CWE-125 in udp_timer() Stefano Brivio
2022-04-05 17:05 ` [PATCH 16/16] arch: Pointer to local outside scope, CWE-562 Stefano Brivio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220405170514.2963773-6-sbrivio@redhat.com \
--to=sbrivio@redhat.com \
--cc=passt-dev@passt.top \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).