[PATCH] vsock/virtio: fix kernel panic from virtio_transport_reset_no_sock

Adalbert Lazăr
2019-03-06T08:53:09Z

On Wed, 6 Mar 2019 09:12:36 +0100, Stefano Garzarella <sgarzare at
redhat.com> wrote:
> > --- a/net/vmw_vsock/virtio_transport_common.c
> > +++ b/net/vmw_vsock/virtio_transport_common.c
> > @@ -662,6 +662,7 @@ static int virtio_transport_reset(struct
vsock_sock *vsk,
> >   */
> >  static int virtio_transport_reset_no_sock(struct virtio_vsock_pkt
*pkt)
> >  {
> > +	const struct virtio_transport *t;
> >  	struct virtio_vsock_pkt_info info = {
> >  		.op = VIRTIO_VSOCK_OP_RST,
> >  		.type = le16_to_cpu(pkt->hdr.type),
> > @@ -680,7 +681,11 @@ static int virtio_transport_reset_no_sock(struct
virtio_vsock_pkt *pkt)
> >  	if (!pkt)
> >  		return -ENOMEM;
> >
> > -	return virtio_transport_get_ops()->send_pkt(pkt);
> > +	t = virtio_transport_get_ops();
> > +	if (!t)
> > +		return -ENOTCONN;
>
> Should be better to do this check before the virtio_transport_alloc_pkt?
>
> Otherwise, I think we should free that packet before to return -ENOTCONN.

Right! :D
I will send a second version.