Skip to content

Commit

Permalink
l2tpv3: fix fd leak
Browse files Browse the repository at this point in the history
In this false branch, fd will leak when it is zero.
Change the testing condition.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
[Fix net_l2tpv3_cleanup as well. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
gongleiarei authored and bonzini committed Nov 17, 2014
1 parent 7737458 commit d4754a9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/l2tpv3.c
Expand Up @@ -516,7 +516,7 @@ static void net_l2tpv3_cleanup(NetClientState *nc)
qemu_purge_queued_packets(nc);
l2tpv3_read_poll(s, false);
l2tpv3_write_poll(s, false);
if (s->fd > 0) {
if (s->fd >= 0) {
close(s->fd);
}
destroy_vector(s->msgvec, MAX_L2TPV3_MSGCNT, IOVSIZE);
Expand Down Expand Up @@ -745,7 +745,7 @@ int net_init_l2tpv3(const NetClientOptions *opts,
return 0;
outerr:
qemu_del_net_client(nc);
if (fd > 0) {
if (fd >= 0) {
close(fd);
}
if (result) {
Expand Down

0 comments on commit d4754a9

Please sign in to comment.