Commit 5b3dc949 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Greg Kroah-Hartman

misc: alcor_pci: Fix an error handling path

A successful ida_simple_get() should be balanced by a corresponding
ida_simple_remove().

Add the missing call in the error handling path of the probe.

While at it, switch to ida_alloc()/ida_free() instead to
ida_simple_get()/ida_simple_remove().
The latter is deprecated and more verbose.

Fixes: 4f556bc0 ("misc: cardreader: add new Alcor Micro Cardreader PCI driver")
Reviewed-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/918a9875b7f67b7f8f123c4446452603422e8c5e.1644136776.git.christophe.jaillet@wanadoo.frSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 353b940c
...@@ -266,7 +266,7 @@ static int alcor_pci_probe(struct pci_dev *pdev, ...@@ -266,7 +266,7 @@ static int alcor_pci_probe(struct pci_dev *pdev,
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
ret = ida_simple_get(&alcor_pci_idr, 0, 0, GFP_KERNEL); ret = ida_alloc(&alcor_pci_idr, GFP_KERNEL);
if (ret < 0) if (ret < 0)
return ret; return ret;
priv->id = ret; priv->id = ret;
...@@ -280,7 +280,8 @@ static int alcor_pci_probe(struct pci_dev *pdev, ...@@ -280,7 +280,8 @@ static int alcor_pci_probe(struct pci_dev *pdev,
ret = pci_request_regions(pdev, DRV_NAME_ALCOR_PCI); ret = pci_request_regions(pdev, DRV_NAME_ALCOR_PCI);
if (ret) { if (ret) {
dev_err(&pdev->dev, "Cannot request region\n"); dev_err(&pdev->dev, "Cannot request region\n");
return -ENOMEM; ret = -ENOMEM;
goto error_free_ida;
} }
if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) { if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) {
...@@ -324,6 +325,8 @@ static int alcor_pci_probe(struct pci_dev *pdev, ...@@ -324,6 +325,8 @@ static int alcor_pci_probe(struct pci_dev *pdev,
error_release_regions: error_release_regions:
pci_release_regions(pdev); pci_release_regions(pdev);
error_free_ida:
ida_free(&alcor_pci_idr, priv->id);
return ret; return ret;
} }
...@@ -337,7 +340,7 @@ static void alcor_pci_remove(struct pci_dev *pdev) ...@@ -337,7 +340,7 @@ static void alcor_pci_remove(struct pci_dev *pdev)
mfd_remove_devices(&pdev->dev); mfd_remove_devices(&pdev->dev);
ida_simple_remove(&alcor_pci_idr, priv->id); ida_free(&alcor_pci_idr, priv->id);
pci_release_regions(pdev); pci_release_regions(pdev);
pci_set_drvdata(pdev, NULL); pci_set_drvdata(pdev, NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment