mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
net: check the existence of peer before trying to pad
There could be case that peer is NULL. This can happen when during
network device hot-add where net device needs to be added first. So
the patch check the existence of peer before trying to do the pad.
Fixes: 969e50b61a
("net: Pad short frames to minimum size before sending from SLiRP/TAP")
Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Message-id: 20210423031803.1479-1-jasowang@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
b1cffefa1b
commit
bc38e31b4e
4 changed files with 8 additions and 3 deletions
|
@ -119,7 +119,7 @@ static ssize_t net_slirp_send_packet(const void *pkt, size_t pkt_len,
|
|||
uint8_t min_pkt[ETH_ZLEN];
|
||||
size_t min_pktsz = sizeof(min_pkt);
|
||||
|
||||
if (!s->nc.peer->do_not_pad) {
|
||||
if (net_peer_needs_padding(&s->nc)) {
|
||||
if (eth_pad_short_frame(min_pkt, &min_pktsz, pkt, pkt_len)) {
|
||||
pkt = min_pkt;
|
||||
pkt_len = min_pktsz;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue