提交 d4754a95 编写于 作者: G Gonglei 提交者: Paolo Bonzini

l2tpv3: fix fd leak

In this false branch, fd will leak when it is zero.
Change the testing condition.
Signed-off-by: NGonglei <arei.gonglei@huawei.com>
[Fix net_l2tpv3_cleanup as well. - Paolo]
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 77374582
...@@ -516,7 +516,7 @@ static void net_l2tpv3_cleanup(NetClientState *nc) ...@@ -516,7 +516,7 @@ static void net_l2tpv3_cleanup(NetClientState *nc)
qemu_purge_queued_packets(nc); qemu_purge_queued_packets(nc);
l2tpv3_read_poll(s, false); l2tpv3_read_poll(s, false);
l2tpv3_write_poll(s, false); l2tpv3_write_poll(s, false);
if (s->fd > 0) { if (s->fd >= 0) {
close(s->fd); close(s->fd);
} }
destroy_vector(s->msgvec, MAX_L2TPV3_MSGCNT, IOVSIZE); destroy_vector(s->msgvec, MAX_L2TPV3_MSGCNT, IOVSIZE);
...@@ -745,7 +745,7 @@ int net_init_l2tpv3(const NetClientOptions *opts, ...@@ -745,7 +745,7 @@ int net_init_l2tpv3(const NetClientOptions *opts,
return 0; return 0;
outerr: outerr:
qemu_del_net_client(nc); qemu_del_net_client(nc);
if (fd > 0) { if (fd >= 0) {
close(fd); close(fd);
} }
if (result) { if (result) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册