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 09:17:23 +0200
commitbda5cb765dd7b1aabf7c7b8d3945d3ead2ed42ad (patch)
tree28be2df63eacc5691f802ce18e77d0847b3803f5
parent8e5a534df784ab91ffde55ed5038e66e8dbb36c8 (diff)
downloadbarebox-bda5cb765dd7b1aabf7c7b8d3945d3ead2ed42ad.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;
}