Skip to content

Commit

Permalink
virtio-input: reset device and detach unused during remove
Browse files Browse the repository at this point in the history
Spec requires a device reset during cleanup, so do it and avoid warn
in virtio core. And detach unused buffers to avoid memory leak.

Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
Jason Wang authored and Michael S. Tsirkin committed Aug 6, 2015
1 parent 74d3329 commit df4198b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/virtio/virtio_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,17 @@ static int virtinput_probe(struct virtio_device *vdev)
static void virtinput_remove(struct virtio_device *vdev)
{
struct virtio_input *vi = vdev->priv;
void *buf;
unsigned long flags;

spin_lock_irqsave(&vi->lock, flags);
vi->ready = false;
spin_unlock_irqrestore(&vi->lock, flags);

input_unregister_device(vi->idev);
vdev->config->reset(vdev);
while ((buf = virtqueue_detach_unused_buf(vi->sts)) != NULL)
kfree(buf);
vdev->config->del_vqs(vdev);
kfree(vi);
}
Expand Down

0 comments on commit df4198b

Please sign in to comment.