Skip to content

Commit

Permalink
misc: pci_endpoint_test: Avoid triggering a BUG()
Browse files Browse the repository at this point in the history
If you call ida_simple_remove(&pci_endpoint_test_ida, id) with a
negative "id" then it triggers an immediate BUG_ON().  Let's not allow
that.

Fixes: 2c156ac ("misc: Add host side PCI driver for PCI test function device")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Dan Carpenter authored and Greg Kroah-Hartman committed Oct 4, 2017
1 parent 378f79c commit 846df24
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/misc/pci_endpoint_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,8 @@ static void pci_endpoint_test_remove(struct pci_dev *pdev)

if (sscanf(misc_device->name, DRV_MODULE_NAME ".%d", &id) != 1)
return;
if (id < 0)
return;

misc_deregister(&test->miscdev);
ida_simple_remove(&pci_endpoint_test_ida, id);
Expand Down

0 comments on commit 846df24

Please sign in to comment.