All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
To: lttng-dev@lists.lttng.org
Subject: [PATCH lttng-ust] Fix: Initialize fd field of struct lttng_ust_elf to -1 at allocation
Date: Wed, 14 Nov 2018 14:38:37 -0500	[thread overview]
Message-ID: <20181114193837.23813-1-jonathan.rajotte-julien__30927.6562919424$1542224213$gmane$org@efficios.com> (raw)

In rare cases when the executable cannot be open, using a default value
of zero lead to invalid close call and fd tracker removal.

fixes #1171

Reported-by: Stefan Palade <stefan.palade@windriver.com>
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
---
 liblttng-ust/lttng-ust-elf.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/liblttng-ust/lttng-ust-elf.c b/liblttng-ust/lttng-ust-elf.c
index c073e7a5..3d6a9379 100644
--- a/liblttng-ust/lttng-ust-elf.c
+++ b/liblttng-ust/lttng-ust-elf.c
@@ -250,6 +250,8 @@ struct lttng_ust_elf *lttng_ust_elf_create(const char *path)
 		goto error;
 	}
 
+	/* Initialize fd field to -1. 0 is a valid fd number */
+	elf->fd = -1;
 
 	elf->path = strdup(path);
 	if (!elf->path) {
-- 
2.17.1

             reply	other threads:[~2018-11-14 19:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-14 19:38 Jonathan Rajotte [this message]
     [not found] <20181114193837.23813-1-jonathan.rajotte-julien@efficios.com>
2019-01-22 15:41 ` [PATCH lttng-ust] Fix: Initialize fd field of struct lttng_ust_elf to -1 at allocation Jonathan Rajotte-Julien
     [not found] ` <20190122154104.GA17450@joraj-alpa>
2019-01-22 21:51   ` Mathieu Desnoyers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='20181114193837.23813-1-jonathan.rajotte-julien__30927.6562919424$1542224213$gmane$org@efficios.com' \
    --to=jonathan.rajotte-julien@efficios.com \
    --cc=lttng-dev@lists.lttng.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.