[PATCH v3 4/4] vhost: add device op to offload the interrupt kick

Maxime Coquelin maxime.coquelin at redhat.com
Wed May 31 14:48:09 CEST 2023



On 5/31/23 14:01, David Marchand wrote:
> Eelco, Maxime,
> 
> On Wed, May 17, 2023 at 11:09 AM Eelco Chaudron <echaudro at 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.

Thanks,
Maxime



More information about the dev mailing list