summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2017-06-02 17:48:28 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-06-06 07:54:17 +0200
commit79e6629b02fb3a296b5dc70f16dec0f8d415ccf8 (patch)
treed8ce6a1ae1d469539272a07fbe0bcfba1bf99748
parent651b3ed2bfd50bf478003c776020dc870e38297f (diff)
downloadbarebox-79e6629b02fb3a296b5dc70f16dec0f8d415ccf8.tar.gz
ratp: avoid using already freed memory
If ratp_establish() fails we would be accessing the ratp_internal struct after having disposed it. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--lib/ratp.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/ratp.c b/lib/ratp.c
index d596a0e..22e8363 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;
}