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)
|
||||
{
|
||||
struct pcu_sock_state *state = (struct pcu_sock_state *)bfd->data;
|
||||
struct gsm_pcu_if *pcu_prim;
|
||||
struct msgb *msg;
|
||||
struct gsm_pcu_if pcu_prim;
|
||||
int rc;
|
||||
|
||||
msg = msgb_alloc(sizeof(*pcu_prim), "pcu_sock_rx");
|
||||
if (!msg)
|
||||
return -ENOMEM;
|
||||
|
||||
pcu_prim = (struct gsm_pcu_if *) msg->tail;
|
||||
|
||||
rc = recv(bfd->fd, msg->tail, msgb_tailroom(msg), 0);
|
||||
rc = recv(bfd->fd, &pcu_prim, sizeof(pcu_prim), 0);
|
||||
if (rc == 0)
|
||||
goto close;
|
||||
|
||||
|
@ -159,16 +152,11 @@ static int pcu_sock_read(struct osmo_fd *bfd)
|
|||
goto close;
|
||||
}
|
||||
|
||||
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);
|
||||
rc = pcu_rx(pcu_prim.msg_type, &pcu_prim);
|
||||
|
||||
return rc;
|
||||
|
||||
close:
|
||||
msgb_free(msg);
|
||||
pcu_sock_close(state, 1);
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue