PCI: switchtec: Fix an error handling path in switchtec_pci_probe()
Subsystems (3)
PATCH 1/1 PCI: switchtec: Fix an error handling path in switchtec_pci_probe()
The commit in Fixes changed the logic on how resources are released and introduced a new switchtec_exit_pci() that need to be called explicitly in order to undo a corresponding switchtec_init_pci().
This was done in the remove function, but not in the probe.
Fix the probe now.
--- drivers/pci/switch/switchtec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pci/switch/switchtec.c +3 -1
@@ -1672,7 +1672,7 @@ static int switchtec_pci_probe(struct pci_dev *pdev, rc =switchtec_init_isr (stdev);if (rc) {dev_err (&stdev->dev,"failed to init isr.\n" ); - goto err_put; + goto err_exit_pci; } iowrite32(SWITCHTEC_EVENT_CLEAR |
@@ -1693,6 +1693,8 @@ static int switchtec_pci_probe(struct pci_dev *pdev, err_devadd:stdev_kill (stdev); +err_exit_pci: +switchtec_exit_pci (stdev); err_put:ida_free (&switchtec_minor_ida,MINOR (stdev->dev.devt));put_device (&stdev->dev);
Signature · 1 line
2.34.1
[+to Daniel, can you take a look? If you like this, I'd like to squash it into df25461119d9 and credit Christophe since that's not upstream yet]
Quoted 39 lines · Christophe JAILLET
The commit in Fixes changed the logic on how resources are released and introduced a new
switchtec_exit_pci()that need to be called explicitly in order to undo a correspondingswitchtec_init_pci().This was done in the remove function, but not in the probe.
Fix the probe now.
Fixes df25461119d9 ("PCI: switchtec: Fix stdev_release() crash after surprise hot remove")Signed-off-by Christophe JAILLET <[email protected]>--- drivers/pci/switch/switchtec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/pci/switch/switchtec.c +3
-1@@ -1672,7 +1672,7 @@ static int switchtec_pci_probe(struct pci_dev *pdev, rc =switchtec_init_isr (stdev);if (rc) {dev_err (&stdev->dev,"failed to init isr.\n" ); - goto err_put; + goto err_exit_pci; } iowrite32(SWITCHTEC_EVENT_CLEAR |@@ -1693,6 +1693,8 @@ static int switchtec_pci_probe(struct pci_dev *pdev, err_devadd:stdev_kill (stdev); +err_exit_pci: +switchtec_exit_pci (stdev); err_put:ida_free (&switchtec_minor_ida,MINOR (stdev->dev.devt));put_device (&stdev->dev);Signature · 1 line
2.34.1
Quoted 8 lines · Bjorn Helgaas
[+to Daniel, can you take a look? If you like this, I'd like to squash it into
df25461119d9and credit Christophe since that's not upstream yet]
Thanks very much for fixing this, Christophe.
The fix looks correct to me. If it can still fold into the previous change, all the better.
Best,
Daniel
PS: without trying to complicate this thread, does one know idr.[ch] well enough to state whether ida_free() could have gone into stdev_release()? The way the two idr_free calls have been placed looks intentional. But stdev_release would look more obvious + cleaner to me. Was only starting to wonder while reviewing the err_put side of this patch.
Bjorn Helgaas
AppliedQuoted 10 lines · Christophe JAILLET
The commit in Fixes changed the logic on how resources are released and introduced a new
switchtec_exit_pci()that need to be called explicitly in order to undo a correspondingswitchtec_init_pci().This was done in the remove function, but not in the probe.
Fix the probe now.
Fixes df25461119d9 ("PCI: switchtec: Fix stdev_release() crash after surprise hot remove")Signed-off-by Christophe JAILLET <[email protected]>
Applied to pci/switchtec for v6.9, thanks!
Quoted 29 lines
--- drivers/pci/switch/switchtec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/pci/switch/switchtec.c +3
-1@@ -1672,7 +1672,7 @@ static int switchtec_pci_probe(struct pci_dev *pdev, rc =switchtec_init_isr (stdev);if (rc) {dev_err (&stdev->dev,"failed to init isr.\n" ); - goto err_put; + goto err_exit_pci; } iowrite32(SWITCHTEC_EVENT_CLEAR |@@ -1693,6 +1693,8 @@ static int switchtec_pci_probe(struct pci_dev *pdev, err_devadd:stdev_kill (stdev); +err_exit_pci: +switchtec_exit_pci (stdev); err_put:ida_free (&switchtec_minor_ida,MINOR (stdev->dev.devt));put_device (&stdev->dev);Signature · 1 line
2.34.1