summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Khoroshilov <khoroshilov@ispras.ru>2012-08-16 17:05:38 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-09-11 15:29:00 -0300
commitf4e4a67a37e7c9624b3e8bb9655db2ae45243f3d (patch)
tree30e1f24316cf86df11f4d95ceca0f46f29091e73
parent4b83a7a75375f9d5edd1fb0067986a0f23695ddd (diff)
downloadop-kernel-dev-f4e4a67a37e7c9624b3e8bb9655db2ae45243f3d.zip
op-kernel-dev-f4e4a67a37e7c9624b3e8bb9655db2ae45243f3d.tar.gz
[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>
-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 ebf3f05..feff57e 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)
ddb_class = class_create(THIS_MODULE, DDB_NAME);
if (IS_ERR(ddb_class)) {
unregister_chrdev(ddb_major, DDB_NAME);
- return -1;
+ return PTR_ERR(ddb_class);
}
ddb_class->devnode = ddb_devnode;
return 0;
@@ -1701,11 +1701,18 @@ static struct pci_driver ddb_pci_driver = {
static __init int module_init_ddbridge(void)
{
+ int ret;
+
printk(KERN_INFO "Digital Devices PCIE bridge driver, "
"Copyright (C) 2010-11 Digital Devices GmbH\n");
- if (ddb_class_create())
- return -1;
- return pci_register_driver(&ddb_pci_driver);
+
+ ret = ddb_class_create();
+ if (ret < 0)
+ return ret;
+ ret = pci_register_driver(&ddb_pci_driver);
+ if (ret < 0)
+ ddb_class_destroy();
+ return ret;
}
static __exit void module_exit_ddbridge(void)
OpenPOWER on IntegriCloud