summaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorKishon Vijay Abraham I <kishon@ti.com>2017-10-11 14:14:37 +0530
committerBjorn Helgaas <bhelgaas@google.com>2017-10-31 15:33:46 -0500
commit139838fffec40296d7235982a1a9b917ba31530f (patch)
tree1751808b4b9c8d48a5ead02d5ff99420754084bf /drivers/misc
parent80068c93688f6143100859c4856f895801c1a1d9 (diff)
downloadop-kernel-dev-139838fffec40296d7235982a1a9b917ba31530f.zip
op-kernel-dev-139838fffec40296d7235982a1a9b917ba31530f.tar.gz
misc: pci_endpoint_test: Fix pci_endpoint_test not releasing resources on remove
sscanf(misc_device->name, DRV_MODULE_NAME ".%d", &id) in pci_endpoint_test_remove() returns 0, which results in returning early without releasing the resources. This is as a result of misc_device not having a valid name. Fix it here. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/pci_endpoint_test.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
index 5e7af21..bf64d15 100644
--- a/drivers/misc/pci_endpoint_test.c
+++ b/drivers/misc/pci_endpoint_test.c
@@ -560,17 +560,24 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
snprintf(name, sizeof(name), DRV_MODULE_NAME ".%d", id);
misc_device = &test->miscdev;
misc_device->minor = MISC_DYNAMIC_MINOR;
- misc_device->name = name;
+ misc_device->name = kstrdup(name, GFP_KERNEL);
+ if (!misc_device->name) {
+ err = -ENOMEM;
+ goto err_ida_remove;
+ }
misc_device->fops = &pci_endpoint_test_fops,
err = misc_register(misc_device);
if (err) {
dev_err(dev, "failed to register device\n");
- goto err_ida_remove;
+ goto err_kfree_name;
}
return 0;
+err_kfree_name:
+ kfree(misc_device->name);
+
err_ida_remove:
ida_simple_remove(&pci_endpoint_test_ida, id);
@@ -603,6 +610,7 @@ static void pci_endpoint_test_remove(struct pci_dev *pdev)
return;
misc_deregister(&test->miscdev);
+ kfree(misc_device->name);
ida_simple_remove(&pci_endpoint_test_ida, id);
for (bar = BAR_0; bar <= BAR_5; bar++) {
if (test->bar[bar])
OpenPOWER on IntegriCloud