[systemd-devel] [PATCH 2/3] [fd leak] Stop leaking an fd in sd_journal_sendv

David Herrmann dh.herrmann at gmail.com
Sat Sep 13 00:43:12 PDT 2014


Hi

On Fri, Sep 12, 2014 at 10:39 AM, Philippe De Swert
<philippedeswert at gmail.com> wrote:
> Hi David,
>
> On 11/09/14 18:43, David Herrmann wrote:
>> Hi
>>>  _public_ int sd_journal_sendv(const struct iovec *iov, int n) {
>>>          PROTECT_ERRNO;
>>> -        int fd;
>>> +        _cleanup_close_ int fd = -1;
>>
>> This does not work. "fd" is used to hold the journal fd, but this is a
>> global fd shared between all callers. See journal_fd().
>> coverity might complain about this as we never close the fd. However,
>> that is totally fine as it will get closed on execve() automatically.
>> There is no reason to close it manually.
>
> Good to know. I guess this goes for all journal related files then? So I
> can mark them correctly in Coverity so they will not be detected wrongly
> in the future.

This is an internal detail to journal_send() and friends. Not sure how
verbosely coverity warns about those, but it should be limited to that
file (and callers of journal_fd()).

Thanks
David


More information about the systemd-devel mailing list