On 31 May 2023, at 14:48, Maxime Coquelin wrote:
> On 5/31/23 14:01, David Marchand wrote:
>> Eelco, Maxime,
>>
>> On Wed, May 17, 2023 at 11:09 AM Eelco Chaudron <echau...@redhat.com> wrote:
>>> @@ -846,6 +848,11 @@ vhost_user_socket_mem_free(struct vhost_user_socket
>>> *vsocket)
>>> vsocket->path = NULL;
>>> }
>>>
>>> + if (vsocket && vsocket->malloc_notify_ops) {
>>> + free(vsocket->malloc_notify_ops);
>>> + vsocket->malloc_notify_ops = NULL;
>>> + }
>>> +
>>> if (vsocket) {
>>> free(vsocket);
>>> vsocket = NULL;
>>
>> Nit: we had several cleanups in the tree to remove patterns like if
>> (ptr) free(ptr).
>> Here, this helper could look for vsocket being NULL first thing, then
>> call free() unconditionnally.
>> And resetting the fields to NULL is probably not that useful, since
>> the vsocket is freed at the end.
>> Wdyt of:
>>
>> static void
>> vhost_user_socket_mem_free(struct vhost_user_socket *vsocket)
>> {
>> if (vsocket == NULL)
>> return;
>>
>> free(vsocket->path);
>> free(vsocket->malloc_notify_ops);
>> free(vsocket);
>> }
>>
>>
>
> It is indeed better, I can fix while applying if Eelco agrees.
Looks good to me.
//Eelco