mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 13:58:34 +00:00
sk-packet: handle errors of xmalloc
Signed-off-by: Andrey Vagin <avagin@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
c9b9aad265
commit
9db8df3dec
17
sk-packet.c
17
sk-packet.c
@@ -275,6 +275,8 @@ int packet_receive_one(struct nlmsghdr *hdr, void *arg)
|
||||
sd->file_id = 0;
|
||||
sd->type = m->pdiag_type;
|
||||
sd->proto = htons(m->pdiag_num);
|
||||
sd->rx = NULL;
|
||||
sd->tx = NULL;
|
||||
memcpy(&sd->nli, RTA_DATA(tb[PACKET_DIAG_INFO]), sizeof(sd->nli));
|
||||
|
||||
if (packet_save_mreqs(sd, tb[PACKET_DIAG_MCLIST]))
|
||||
@@ -287,17 +289,24 @@ int packet_receive_one(struct nlmsghdr *hdr, void *arg)
|
||||
|
||||
if (tb[PACKET_DIAG_RX_RING]) {
|
||||
sd->rx = xmalloc(sizeof(*sd->rx));
|
||||
if (sd->rx == NULL)
|
||||
goto err;
|
||||
memcpy(sd->rx, RTA_DATA(tb[PACKET_DIAG_RX_RING]), sizeof(*sd->rx));
|
||||
} else
|
||||
sd->rx = NULL;
|
||||
}
|
||||
|
||||
if (tb[PACKET_DIAG_TX_RING]) {
|
||||
sd->tx = xmalloc(sizeof(*sd->tx));
|
||||
if (sd->tx == NULL)
|
||||
goto err;
|
||||
memcpy(sd->tx, RTA_DATA(tb[PACKET_DIAG_TX_RING]), sizeof(*sd->tx));
|
||||
} else
|
||||
sd->tx = NULL;
|
||||
}
|
||||
|
||||
return sk_collect_one(m->pdiag_ino, PF_PACKET, &sd->sd);
|
||||
err:
|
||||
xfree(sd->tx);
|
||||
xfree(sd->rx);
|
||||
xfree(sd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int get_socket_fd(int pid, VmaEntry *vma)
|
||||
|
Reference in New Issue
Block a user