common/pcu_sock.c: fix possible memleaks in pcu_sock_read()

Change-Id: I58352e5f2b5715361c7089d0e134a42975171022
This commit is contained in:
Vadim Yanitskiy 2019-04-12 21:29:43 +07:00
parent 620c74b7fe
commit 720971c6a0
1 changed files with 4 additions and 1 deletions

View File

@ -790,14 +790,17 @@ static int pcu_sock_read(struct osmo_fd *bfd)
goto close;
if (rc < 0) {
if (errno == EAGAIN)
if (errno == EAGAIN) {
msgb_free(msg);
return 0;
}
goto close;
}
if (rc < sizeof(*pcu_prim)) {
LOGP(DPCU, LOGL_ERROR, "Received %d bytes on PCU Socket, but primitive size "
"is %lu, discarding\n", rc, sizeof(*pcu_prim));
msgb_free(msg);
return 0;
}