[systemd-devel] [PATCH 2/3] [fd leak] Stop leaking an fd in sd_journal_sendv
David Herrmann
dh.herrmann at gmail.com
Thu Sep 11 08:43:50 PDT 2014
Hi
On Wed, Sep 10, 2014 at 9:14 PM, <philippedeswert at gmail.com> wrote:
> From: Philippe De Swert <philippedeswert at gmail.com>
>
> Found with Coverity. Fixes: CID#996435
>
> Signed-off-by: Philippe De Swert <philippedeswert at gmail.com>
> ---
> src/journal/journal-send.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/journal/journal-send.c b/src/journal/journal-send.c
> index bb1ef66..b7cc4bd 100644
> --- a/src/journal/journal-send.c
> +++ b/src/journal/journal-send.c
> @@ -198,7 +198,7 @@ finish:
>
> _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.
Thanks
David
> _cleanup_close_ int buffer_fd = -1;
> struct iovec *w;
> uint64_t *l;
> --
> 1.8.3.2
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
More information about the systemd-devel
mailing list