aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/pci/ddbridge/ddbridge-core.c
diff options
context:
space:
mode:
authorAlexey Khoroshilov <khoroshilov@ispras.ru>2012-08-16 16:05:38 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-09-11 14:29:00 -0400
commitf4e4a67a37e7c9624b3e8bb9655db2ae45243f3d (patch)
tree30e1f24316cf86df11f4d95ceca0f46f29091e73 /drivers/media/pci/ddbridge/ddbridge-core.c
parent4b83a7a75375f9d5edd1fb0067986a0f23695ddd (diff)
[media] ddbridge: fix error handling in module_init_ddbridge()
If pci_register_driver() failed, resources allocated in ddb_class_create() are leaked. The patch fixes it as well as it replaces -1 with correct error code in ddb_class_create(). Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/pci/ddbridge/ddbridge-core.c')
-rw-r--r--drivers/media/pci/ddbridge/ddbridge-core.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c
index ebf3f05839d2..feff57ee5a08 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -1497,7 +1497,7 @@ static int ddb_class_create(void)
1497 ddb_class = class_create(THIS_MODULE, DDB_NAME); 1497 ddb_class = class_create(THIS_MODULE, DDB_NAME);
1498 if (IS_ERR(ddb_class)) { 1498 if (IS_ERR(ddb_class)) {
1499 unregister_chrdev(ddb_major, DDB_NAME); 1499 unregister_chrdev(ddb_major, DDB_NAME);
1500 return -1; 1500 return PTR_ERR(ddb_class);
1501 } 1501 }
1502 ddb_class->devnode = ddb_devnode; 1502 ddb_class->devnode = ddb_devnode;
1503 return 0; 1503 return 0;
@@ -1701,11 +1701,18 @@ static struct pci_driver ddb_pci_driver = {
1701 1701
1702static __init int module_init_ddbridge(void) 1702static __init int module_init_ddbridge(void)
1703{ 1703{
1704 int ret;
1705
1704 printk(KERN_INFO "Digital Devices PCIE bridge driver, " 1706 printk(KERN_INFO "Digital Devices PCIE bridge driver, "
1705 "Copyright (C) 2010-11 Digital Devices GmbH\n"); 1707 "Copyright (C) 2010-11 Digital Devices GmbH\n");
1706 if (ddb_class_create()) 1708
1707 return -1; 1709 ret = ddb_class_create();
1708 return pci_register_driver(&ddb_pci_driver); 1710 if (ret < 0)
1711 return ret;
1712 ret = pci_register_driver(&ddb_pci_driver);
1713 if (ret < 0)
1714 ddb_class_destroy();
1715 return ret;
1709} 1716}
1710 1717
1711static __exit void module_exit_ddbridge(void) 1718static __exit void module_exit_ddbridge(void)