Commit 4d1f5155 authored by Arseniy Krasnov's avatar Arseniy Krasnov Committed by Paolo Abeni

virtio/vsock: check transport before skb allocation

Pointer to transport could be checked before allocation of skbuff, thus
there is no need to free skbuff when this pointer is NULL.
Signed-off-by: default avatarArseniy Krasnov <AVKrasnov@sberdevices.ru>
Reviewed-by: default avatarBobby Eshleman <bobby.eshleman@bytedance.com>
Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
Reviewed-by: default avatarPavan Chebbi <pavan.chebbi@broadcom.com>
Link: https://lore.kernel.org/r/08d61bef-0c11-c7f9-9266-cb2109070314@sberdevices.ruSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 56c874f7
...@@ -850,6 +850,9 @@ static int virtio_transport_reset_no_sock(const struct virtio_transport *t, ...@@ -850,6 +850,9 @@ static int virtio_transport_reset_no_sock(const struct virtio_transport *t,
if (le16_to_cpu(hdr->op) == VIRTIO_VSOCK_OP_RST) if (le16_to_cpu(hdr->op) == VIRTIO_VSOCK_OP_RST)
return 0; return 0;
if (!t)
return -ENOTCONN;
reply = virtio_transport_alloc_skb(&info, 0, reply = virtio_transport_alloc_skb(&info, 0,
le64_to_cpu(hdr->dst_cid), le64_to_cpu(hdr->dst_cid),
le32_to_cpu(hdr->dst_port), le32_to_cpu(hdr->dst_port),
...@@ -858,11 +861,6 @@ static int virtio_transport_reset_no_sock(const struct virtio_transport *t, ...@@ -858,11 +861,6 @@ static int virtio_transport_reset_no_sock(const struct virtio_transport *t,
if (!reply) if (!reply)
return -ENOMEM; return -ENOMEM;
if (!t) {
kfree_skb(reply);
return -ENOTCONN;
}
return t->send_pkt(reply); return t->send_pkt(reply);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment