drivers/video: add missing pci_dev_get
pci_get_device does a pci_dev_get, so pci_dev_put needs to be called in an error case The problem was fixed using the following semantic patch. (http://www.emn.fr/x-info/coccinelle/) // <smpl> @exists@ type T1,T2; identifier E; statement S,S1; expression x1,x2,x3; expression test; int ret != 0; @@ struct pci_dev *E; ... ( E = \(pci_get_slot\|pci_get_device\|pci_get_bus_and_slot\)(...); if (E == NULL) S | if ((E = \(pci_get_slot\|pci_get_device\|pci_get_bus_and_slot\)(...)) == NULL) S ) ... when != pci_dev_put(...,(T1)E,...) when != if (E != NULL) { ... pci_dev_put(...,(T1)E,...); ...} when != x1 = (T1)E when != E = x3; when any ( if (E == NULL) S1 | if (test) + { ( + pci_dev_put(E); return; | + pci_dev_put(E); return ret; ) + } | if (test) { ... when != pci_dev_put(...,(T2)E,...) when != if (E != NULL) { ... pci_dev_put(...,(T2)E,...); ...} when != x2 = (T2)E ( + pci_dev_put(E); return; | + pci_dev_put(E); return ret; ) } ) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Cc: "David S. Miller" <davem@davemloft.net> Cc: "Antonino A. Daplas" <adaplas@pol.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
5eb03a4ab2
commit
625fcaf973
|
@ -400,6 +400,7 @@ int __init igafb_init(void)
|
||||||
info = kzalloc(size, GFP_ATOMIC);
|
info = kzalloc(size, GFP_ATOMIC);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
printk("igafb_init: can't alloc fb_info\n");
|
printk("igafb_init: can't alloc fb_info\n");
|
||||||
|
pci_dev_put(pdev);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,12 +410,14 @@ int __init igafb_init(void)
|
||||||
if ((addr = pdev->resource[0].start) == 0) {
|
if ((addr = pdev->resource[0].start) == 0) {
|
||||||
printk("igafb_init: no memory start\n");
|
printk("igafb_init: no memory start\n");
|
||||||
kfree(info);
|
kfree(info);
|
||||||
|
pci_dev_put(pdev);
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((info->screen_base = ioremap(addr, 1024*1024*2)) == 0) {
|
if ((info->screen_base = ioremap(addr, 1024*1024*2)) == 0) {
|
||||||
printk("igafb_init: can't remap %lx[2M]\n", addr);
|
printk("igafb_init: can't remap %lx[2M]\n", addr);
|
||||||
kfree(info);
|
kfree(info);
|
||||||
|
pci_dev_put(pdev);
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,6 +452,7 @@ int __init igafb_init(void)
|
||||||
printk("igafb_init: can't remap %lx[4K]\n", igafb_fix.mmio_start);
|
printk("igafb_init: can't remap %lx[4K]\n", igafb_fix.mmio_start);
|
||||||
iounmap((void *)info->screen_base);
|
iounmap((void *)info->screen_base);
|
||||||
kfree(info);
|
kfree(info);
|
||||||
|
pci_dev_put(pdev);
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,6 +470,7 @@ int __init igafb_init(void)
|
||||||
iounmap((void *)par->io_base);
|
iounmap((void *)par->io_base);
|
||||||
iounmap(info->screen_base);
|
iounmap(info->screen_base);
|
||||||
kfree(info);
|
kfree(info);
|
||||||
|
pci_dev_put(pdev);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue