mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Aleksander Morgado <aleksander@aleksander.es>
To: barebox@lists.infradead.org
Cc: Aleksander Morgado <aleksander@aleksander.es>
Subject: [PATCH] ratp: avoid using already freed memory
Date: Fri,  2 Jun 2017 17:48:28 +0200	[thread overview]
Message-ID: <20170602154828.4429-1-aleksander@aleksander.es> (raw)

If ratp_establish() fails we would be accessing the ratp_internal
struct after having disposed it.

Signed-off-by: Aleksander Morgado <aleksander@aleksander.es>
---
 lib/ratp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/ratp.c b/lib/ratp.c
index d596a0e8b..22e83636f 100644
--- a/lib/ratp.c
+++ b/lib/ratp.c
@@ -1658,6 +1658,8 @@ int ratp_establish(struct ratp *ratp, bool active, int timeout_ms)
 	}
 
 out:
+	ri->in_ratp--;
+
 	if (ret) {
 		free(ri->recvbuf);
 		free(ri->sendbuf);
@@ -1665,8 +1667,6 @@ out:
 		ratp->internal = NULL;
 	}
 
-	ri->in_ratp--;
-
 	return ret;
 }
 
-- 
2.13.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2017-06-02 15:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-02 15:48 Aleksander Morgado [this message]
2017-06-06  5:54 ` Sascha Hauer

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=20170602154828.4429-1-aleksander@aleksander.es \
    --to=aleksander@aleksander.es \
    --cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox