diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2017-06-02 17:48:28 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2017-06-06 07:54:17 +0200 |
commit | 79e6629b02fb3a296b5dc70f16dec0f8d415ccf8 (patch) | |
tree | d8ce6a1ae1d469539272a07fbe0bcfba1bf99748 | |
parent | 651b3ed2bfd50bf478003c776020dc870e38297f (diff) | |
download | barebox-79e6629b02fb3a296b5dc70f16dec0f8d415ccf8.tar.gz barebox-79e6629b02fb3a296b5dc70f16dec0f8d415ccf8.tar.xz |
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.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/ratp.c b/lib/ratp.c index d596a0e8b2..22e83636fd 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; } |