osmobts_sock.cpp: pcu_sock_read(): use stack buffer, not heap
We don't really need to use the message buffer (on heap), because it's never getting passed to pcu_rx(). Let's use a buffer on stack. Change-Id: I4cb8ca80513df7b71e1438da2e82799be6be1fa0
This commit is contained in:
parent
aef6bf43e5
commit
c7849c2dfe
|
@ -139,17 +139,10 @@ for the reset. */
|
||||||
static int pcu_sock_read(struct osmo_fd *bfd)
|
static int pcu_sock_read(struct osmo_fd *bfd)
|
||||||
{
|
{
|
||||||
struct pcu_sock_state *state = (struct pcu_sock_state *)bfd->data;
|
struct pcu_sock_state *state = (struct pcu_sock_state *)bfd->data;
|
||||||
struct gsm_pcu_if *pcu_prim;
|
struct gsm_pcu_if pcu_prim;
|
||||||
struct msgb *msg;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
msg = msgb_alloc(sizeof(*pcu_prim), "pcu_sock_rx");
|
rc = recv(bfd->fd, &pcu_prim, sizeof(pcu_prim), 0);
|
||||||
if (!msg)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
pcu_prim = (struct gsm_pcu_if *) msg->tail;
|
|
||||||
|
|
||||||
rc = recv(bfd->fd, msg->tail, msgb_tailroom(msg), 0);
|
|
||||||
if (rc == 0)
|
if (rc == 0)
|
||||||
goto close;
|
goto close;
|
||||||
|
|
||||||
|
@ -159,16 +152,11 @@ static int pcu_sock_read(struct osmo_fd *bfd)
|
||||||
goto close;
|
goto close;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = pcu_rx(pcu_prim->msg_type, pcu_prim);
|
rc = pcu_rx(pcu_prim.msg_type, &pcu_prim);
|
||||||
|
|
||||||
/* as we always synchronously process the message in pcu_rx() and
|
|
||||||
* its callbacks, we can free the message here. */
|
|
||||||
msgb_free(msg);
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
close:
|
close:
|
||||||
msgb_free(msg);
|
|
||||||
pcu_sock_close(state, 1);
|
pcu_sock_close(state, 1);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue