diff options
author | Julia Lawall <julia@diku.dk> | 2008-02-06 04:39:23 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-06 13:41:16 -0500 |
commit | 625fcaf97340b9409e41fcefbbd18e02e3a9e9dd (patch) | |
tree | 3ea04c28d5528132d8aa6975579b04dd6e89013f /drivers/video/igafb.c | |
parent | 5eb03a4ab239d8769fa13df6c894d618ecae1b50 (diff) |
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>
Diffstat (limited to 'drivers/video/igafb.c')
-rw-r--r-- | drivers/video/igafb.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/video/igafb.c b/drivers/video/igafb.c index b87ea21d3d78..3a81060137a2 100644 --- a/drivers/video/igafb.c +++ b/drivers/video/igafb.c | |||
@@ -400,6 +400,7 @@ int __init igafb_init(void) | |||
400 | info = kzalloc(size, GFP_ATOMIC); | 400 | info = kzalloc(size, GFP_ATOMIC); |
401 | if (!info) { | 401 | if (!info) { |
402 | printk("igafb_init: can't alloc fb_info\n"); | 402 | printk("igafb_init: can't alloc fb_info\n"); |
403 | pci_dev_put(pdev); | ||
403 | return -ENOMEM; | 404 | return -ENOMEM; |
404 | } | 405 | } |
405 | 406 | ||
@@ -409,12 +410,14 @@ int __init igafb_init(void) | |||
409 | if ((addr = pdev->resource[0].start) == 0) { | 410 | if ((addr = pdev->resource[0].start) == 0) { |
410 | printk("igafb_init: no memory start\n"); | 411 | printk("igafb_init: no memory start\n"); |
411 | kfree(info); | 412 | kfree(info); |
413 | pci_dev_put(pdev); | ||
412 | return -ENXIO; | 414 | return -ENXIO; |
413 | } | 415 | } |
414 | 416 | ||
415 | if ((info->screen_base = ioremap(addr, 1024*1024*2)) == 0) { | 417 | if ((info->screen_base = ioremap(addr, 1024*1024*2)) == 0) { |
416 | printk("igafb_init: can't remap %lx[2M]\n", addr); | 418 | printk("igafb_init: can't remap %lx[2M]\n", addr); |
417 | kfree(info); | 419 | kfree(info); |
420 | pci_dev_put(pdev); | ||
418 | return -ENXIO; | 421 | return -ENXIO; |
419 | } | 422 | } |
420 | 423 | ||
@@ -449,6 +452,7 @@ int __init igafb_init(void) | |||
449 | printk("igafb_init: can't remap %lx[4K]\n", igafb_fix.mmio_start); | 452 | printk("igafb_init: can't remap %lx[4K]\n", igafb_fix.mmio_start); |
450 | iounmap((void *)info->screen_base); | 453 | iounmap((void *)info->screen_base); |
451 | kfree(info); | 454 | kfree(info); |
455 | pci_dev_put(pdev); | ||
452 | return -ENXIO; | 456 | return -ENXIO; |
453 | } | 457 | } |
454 | 458 | ||
@@ -466,6 +470,7 @@ int __init igafb_init(void) | |||
466 | iounmap((void *)par->io_base); | 470 | iounmap((void *)par->io_base); |
467 | iounmap(info->screen_base); | 471 | iounmap(info->screen_base); |
468 | kfree(info); | 472 | kfree(info); |
473 | pci_dev_put(pdev); | ||
469 | return -ENOMEM; | 474 | return -ENOMEM; |
470 | } | 475 | } |
471 | 476 | ||