提交 139838ff 编写于 作者: K Kishon Vijay Abraham I 提交者: Bjorn Helgaas

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: NKishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
上级 80068c93
...@@ -560,17 +560,24 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, ...@@ -560,17 +560,24 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,
snprintf(name, sizeof(name), DRV_MODULE_NAME ".%d", id); snprintf(name, sizeof(name), DRV_MODULE_NAME ".%d", id);
misc_device = &test->miscdev; misc_device = &test->miscdev;
misc_device->minor = MISC_DYNAMIC_MINOR; 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, misc_device->fops = &pci_endpoint_test_fops,
err = misc_register(misc_device); err = misc_register(misc_device);
if (err) { if (err) {
dev_err(dev, "failed to register device\n"); dev_err(dev, "failed to register device\n");
goto err_ida_remove; goto err_kfree_name;
} }
return 0; return 0;
err_kfree_name:
kfree(misc_device->name);
err_ida_remove: err_ida_remove:
ida_simple_remove(&pci_endpoint_test_ida, id); ida_simple_remove(&pci_endpoint_test_ida, id);
...@@ -603,6 +610,7 @@ static void pci_endpoint_test_remove(struct pci_dev *pdev) ...@@ -603,6 +610,7 @@ static void pci_endpoint_test_remove(struct pci_dev *pdev)
return; return;
misc_deregister(&test->miscdev); misc_deregister(&test->miscdev);
kfree(misc_device->name);
ida_simple_remove(&pci_endpoint_test_ida, id); ida_simple_remove(&pci_endpoint_test_ida, id);
for (bar = BAR_0; bar <= BAR_5; bar++) { for (bar = BAR_0; bar <= BAR_5; bar++) {
if (test->bar[bar]) if (test->bar[bar])
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册