Re: [PATCH 3/4] rpc: avoid memory leak on error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]