
On 06/30/2011 07:05 PM, Wen Congyang wrote:
At 07/01/2011 07:36 AM, Eric Blake Write:
Detected by Coverity. The leak is on an error path, but I'm not sure whether that path is likely to be triggered in practice.
error: virNetSocketFree(clientsock); + virNetServerClientFree(client);
If svc->dispatchFunc is NULL, we will goto here to do cleanup. Unfortunately, client->sock is clientsock and it will be freed again in virNetServerClientFree(). It may cause libvirtd crashed.
If svc->dispatchFunc() failed, we close and free client. But we only free client here, not close it here. Do we need to close it here?
I think the cleanup code should like this:
if (client) { virNetServerClientClose(client); virNetServerClientFree(client); } else { virNetSocketFree(clientsock); }
Makes sense to me, but I'd rather hear Dan's take on it as author of that code. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org