summaryrefslogtreecommitdiffstats
path: root/drivers/virtio
diff options
context:
space:
mode:
authorAndrew Vagin <avagin@openvz.org>2013-07-02 02:05:13 -0400
committerRusty Russell <rusty@rustcorp.com.au>2013-07-02 02:12:02 -0400
commitf11335db5e3901f6afc2eafa03a3b970562538b2 (patch)
treee5f130f2f27d699f06a1ca1c3eadf65b83875322 /drivers/virtio
parent95cc2c02cfe08b8bb910d2563725f96a5c48c327 (diff)
virtio-pci: fix leaks of msix_affinity_masks
vp_dev->msix_vectors should be initialized before allocating msix_affinity_masks, otherwise vp_free_vectors will not free these objects. unreferenced object 0xffff88010f969d88 (size 512): comm "systemd-udevd", pid 158, jiffies 4294673645 (age 80.545s) hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<ffffffff816e455e>] kmemleak_alloc+0x5e/0xc0 [<ffffffff811aa7f1>] kmem_cache_alloc_node_trace+0x141/0x2c0 [<ffffffff8133ba23>] alloc_cpumask_var_node+0x23/0x80 [<ffffffff8133ba8e>] alloc_cpumask_var+0xe/0x10 [<ffffffff813fdb3d>] vp_try_to_find_vqs+0x25d/0x810 [<ffffffff813fe171>] vp_find_vqs+0x81/0xb0 [<ffffffffa00d2a05>] init_vqs+0x85/0x120 [virtio_balloon] [<ffffffffa00d2c29>] virtballoon_probe+0xf9/0x1a0 [virtio_balloon] [<ffffffff813fb61e>] virtio_dev_probe+0xde/0x140 [<ffffffff814452b8>] driver_probe_device+0x98/0x3a0 [<ffffffff8144566b>] __driver_attach+0xab/0xb0 [<ffffffff814432f4>] bus_for_each_dev+0x94/0xb0 [<ffffffff81444f4e>] driver_attach+0x1e/0x20 [<ffffffff81444910>] bus_add_driver+0x200/0x280 [<ffffffff81445c14>] driver_register+0x74/0x160 [<ffffffff813fb7d0>] register_virtio_driver+0x20/0x40 v2: change msix_vectors uncoditionaly in vp_free_vectors Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Jason Wang <jasowang@redhat.com> Signed-off-by: Andrew Vagin <avagin@openvz.org> Acked-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/virtio')
-rw-r--r--drivers/virtio/virtio_pci.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index a7ce73029f59..1aba255b5879 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -289,9 +289,9 @@ static void vp_free_vectors(struct virtio_device *vdev)
289 289
290 pci_disable_msix(vp_dev->pci_dev); 290 pci_disable_msix(vp_dev->pci_dev);
291 vp_dev->msix_enabled = 0; 291 vp_dev->msix_enabled = 0;
292 vp_dev->msix_vectors = 0;
293 } 292 }
294 293
294 vp_dev->msix_vectors = 0;
295 vp_dev->msix_used_vectors = 0; 295 vp_dev->msix_used_vectors = 0;
296 kfree(vp_dev->msix_names); 296 kfree(vp_dev->msix_names);
297 vp_dev->msix_names = NULL; 297 vp_dev->msix_names = NULL;
@@ -309,6 +309,8 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors,
309 unsigned i, v; 309 unsigned i, v;
310 int err = -ENOMEM; 310 int err = -ENOMEM;
311 311
312 vp_dev->msix_vectors = nvectors;
313
312 vp_dev->msix_entries = kmalloc(nvectors * sizeof *vp_dev->msix_entries, 314 vp_dev->msix_entries = kmalloc(nvectors * sizeof *vp_dev->msix_entries,
313 GFP_KERNEL); 315 GFP_KERNEL);
314 if (!vp_dev->msix_entries) 316 if (!vp_dev->msix_entries)
@@ -336,7 +338,6 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors,
336 err = -ENOSPC; 338 err = -ENOSPC;
337 if (err) 339 if (err)
338 goto error; 340 goto error;
339 vp_dev->msix_vectors = nvectors;
340 vp_dev->msix_enabled = 1; 341 vp_dev->msix_enabled = 1;
341 342
342 /* Set the vector used for configuration */ 343 /* Set the vector used for configuration */