On 5/10/21 9:04 PM, Dumitru Ceara wrote:
> On 5/10/21 12:13 PM, Dumitru Ceara wrote:
>>> +/* Creates a new pstream named 'name' that will accept new replay 
>>> connections
>>> + * reading them from the replay file and stores a pointer to the stream in
>>> + * '*pstreamp'.
>>> + *
>>> + * Takes ownership of 'name'.
>>> + *
>>> + * Returns 0 if successful, otherwise a positive errno value. */
>>> +static int
>>> +pstream_replay_listen(const char *name, char *suffix OVS_UNUSED,
>>> +                      struct pstream **pstreamp, uint8_t dscp OVS_UNUSED)
>>> +{
>>> +    int seqno = 0, error = 0, listen_result;
>>> +    replay_file_t f;
>>> +
>>> +    ovs_replay_lock();
>>> +    error = ovs_replay_file_open(name, &f, &seqno);
>>> +    if (error) {
>>> +        VLOG_ERR("%s: failed to open pstream.", name);> +        goto 
>>> unlock;
>> 'name' is leaked here.
>>
>>> +    }
>>> +
>>> +    error = ovs_replay_read(f, NULL, 0, &listen_result, &seqno, true);
>>> +    if (error) {
>>> +        VLOG_ERR("%s: failed to read 'listen' record.", name);
>>> +        ovs_replay_file_close(f);
>>> +        goto unlock;
>> Same here.
>>
>>> +    }
>>> +
>>> +    if (listen_result) {
>>> +        error = -listen_result;
>>> +        ovs_replay_file_close(f);
>>> +        goto unlock;
>> Here too.
>>
>>> +    }
>>> +
>>> +    struct replay_pstream *ps = xmalloc(sizeof *ps);
>>> +    pstream_init(&ps->pstream, &preplay_pstream_class, xstrdup(name));
>> I guess the xstrdup(name) is not needed, otherwise we don't really take
>> ownership of 'name' and we actually leak it.
>>
> 
> Actually, this is wrong, sorry for the noise.  'name' is not leaked, but
> the function comment is misleading.
> 

Good catch!  I removed the incorrect comment.
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to