aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/virtio
diff options
context:
space:
mode:
authorJason Wang <jasowang@redhat.com>2015-08-06 01:54:21 -0400
committerMichael S. Tsirkin <mst@redhat.com>2015-08-06 03:40:35 -0400
commitdf4198b1e0c4a7d1adde1e5c2ceb67ac10b391bb (patch)
tree7a2f88d1e80de2f14e6cf43a12ecf2073dc1f2ca /drivers/virtio
parent74d33293e467df61de1b1d8b2fbe29e550dec33b (diff)
virtio-input: reset device and detach unused during remove
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>
Diffstat (limited to 'drivers/virtio')
-rw-r--r--drivers/virtio/virtio_input.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/virtio/virtio_input.c b/drivers/virtio/virtio_input.c
index 60e2a1677563..c96944b59856 100644
--- a/drivers/virtio/virtio_input.c
+++ b/drivers/virtio/virtio_input.c
@@ -313,6 +313,7 @@ err_init_vq:
313static void virtinput_remove(struct virtio_device *vdev) 313static void virtinput_remove(struct virtio_device *vdev)
314{ 314{
315 struct virtio_input *vi = vdev->priv; 315 struct virtio_input *vi = vdev->priv;
316 void *buf;
316 unsigned long flags; 317 unsigned long flags;
317 318
318 spin_lock_irqsave(&vi->lock, flags); 319 spin_lock_irqsave(&vi->lock, flags);
@@ -320,6 +321,9 @@ static void virtinput_remove(struct virtio_device *vdev)
320 spin_unlock_irqrestore(&vi->lock, flags); 321 spin_unlock_irqrestore(&vi->lock, flags);
321 322
322 input_unregister_device(vi->idev); 323 input_unregister_device(vi->idev);
324 vdev->config->reset(vdev);
325 while ((buf = virtqueue_detach_unused_buf(vi->sts)) != NULL)
326 kfree(buf);
323 vdev->config->del_vqs(vdev); 327 vdev->config->del_vqs(vdev);
324 kfree(vi); 328 kfree(vi);
325} 329}