mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] ratp: avoid using already freed memory
@ 2017-06-02 15:48 Aleksander Morgado
  2017-06-06  5:54 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Aleksander Morgado @ 2017-06-02 15:48 UTC (permalink / raw)
  To: barebox; +Cc: Aleksander Morgado

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-06  5:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-02 15:48 [PATCH] ratp: avoid using already freed memory Aleksander Morgado
2017-06-06  5:54 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox