Showing error 851

User: Jiri Slaby
Error type: Resource Leak
Error type description: The code omits to put the resource to the system for reuse
File location: virt/kvm/kvm_main.c
Line in file: 270
Project: Linux Kernel
Project version: 2.6.28
Tools: Stanse (1.2)
Entered: 2011-11-07 22:40:13 UTC


Source:

 240        kvm_free_assigned_device(kvm, match);
 241        return r;
 242}
 243
 244static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
 245                                      struct kvm_assigned_pci_dev *assigned_dev)
 246{
 247        int r = 0;
 248        struct kvm_assigned_dev_kernel *match;
 249        struct pci_dev *dev;
 250
 251        mutex_lock(&kvm->lock);
 252
 253        match = kvm_find_assigned_dev(&kvm->arch.assigned_dev_head,
 254                                      assigned_dev->assigned_dev_id);
 255        if (match) {
 256                /* device already assigned */
 257                r = -EINVAL;
 258                goto out;
 259        }
 260
 261        match = kzalloc(sizeof(struct kvm_assigned_dev_kernel), GFP_KERNEL);
 262        if (match == NULL) {
 263                printk(KERN_INFO "%s: Couldn't allocate memory\n",
 264                       __func__);
 265                r = -ENOMEM;
 266                goto out;
 267        }
 268        dev = pci_get_bus_and_slot(assigned_dev->busnr,
 269                                   assigned_dev->devfn);
 270        if (!dev) {
 271                printk(KERN_INFO "%s: host device not found\n", __func__);
 272                r = -EINVAL;
 273                goto out_free;
 274        }
 275        if (pci_enable_device(dev)) {
 276                printk(KERN_INFO "%s: Could not enable PCI device\n", __func__);
 277                r = -EBUSY;
 278                goto out_put;
 279        }
 280        r = pci_request_regions(dev, "kvm_assigned_device");
Show full sources