public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI: switchtec: Fix an error handling path in switchtec_pci_probe()
@ 2023-12-24 14:30 Christophe JAILLET
  2023-12-28 23:56 ` Bjorn Helgaas
  2024-02-08 21:36 ` Bjorn Helgaas
  0 siblings, 2 replies; 4+ messages in thread
From: Christophe JAILLET @ 2023-12-24 14:30 UTC (permalink / raw)
  To: Kurt Schwemmer, Logan Gunthorpe, Bjorn Helgaas, Dmitry Safonov,
	Daniel Stodden
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-pci

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.

Fixes: df25461119d9 ("PCI: switchtec: Fix stdev_release() crash after surprise hot remove")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/pci/switch/switchtec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
index 1804794d0e68..5a4adf6c04cf 100644
--- a/drivers/pci/switch/switchtec.c
+++ b/drivers/pci/switch/switchtec.c
@@ -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);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] PCI: switchtec: Fix an error handling path in switchtec_pci_probe()
  2023-12-24 14:30 [PATCH] PCI: switchtec: Fix an error handling path in switchtec_pci_probe() Christophe JAILLET
@ 2023-12-28 23:56 ` Bjorn Helgaas
  2023-12-29  1:39   ` Daniel Stodden
  2024-02-08 21:36 ` Bjorn Helgaas
  1 sibling, 1 reply; 4+ messages in thread
From: Bjorn Helgaas @ 2023-12-28 23:56 UTC (permalink / raw)
  To: Christophe JAILLET, Daniel Stodden
  Cc: Kurt Schwemmer, Logan Gunthorpe, Bjorn Helgaas, Dmitry Safonov,
	linux-kernel, kernel-janitors, linux-pci

[+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]

On Sun, Dec 24, 2023 at 03:30:01PM +0100, Christophe JAILLET wrote:
> 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.
> 
> Fixes: df25461119d9 ("PCI: switchtec: Fix stdev_release() crash after surprise hot remove")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/pci/switch/switchtec.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
> index 1804794d0e68..5a4adf6c04cf 100644
> --- a/drivers/pci/switch/switchtec.c
> +++ b/drivers/pci/switch/switchtec.c
> @@ -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);
> -- 
> 2.34.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] PCI: switchtec: Fix an error handling path in switchtec_pci_probe()
  2023-12-28 23:56 ` Bjorn Helgaas
@ 2023-12-29  1:39   ` Daniel Stodden
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Stodden @ 2023-12-29  1:39 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Christophe JAILLET, Kurt Schwemmer, Logan Gunthorpe,
	Bjorn Helgaas, Dmitry Safonov, linux-kernel, kernel-janitors,
	linux-pci




> On Dec 28, 2023, at 3:56 PM, Bjorn Helgaas <helgaas@kernel.org> wrote:
> 
> [+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]

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] PCI: switchtec: Fix an error handling path in switchtec_pci_probe()
  2023-12-24 14:30 [PATCH] PCI: switchtec: Fix an error handling path in switchtec_pci_probe() Christophe JAILLET
  2023-12-28 23:56 ` Bjorn Helgaas
@ 2024-02-08 21:36 ` Bjorn Helgaas
  1 sibling, 0 replies; 4+ messages in thread
From: Bjorn Helgaas @ 2024-02-08 21:36 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Kurt Schwemmer, Logan Gunthorpe, Bjorn Helgaas, Dmitry Safonov,
	Daniel Stodden, linux-kernel, kernel-janitors, linux-pci

On Sun, Dec 24, 2023 at 03:30:01PM +0100, Christophe JAILLET wrote:
> 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.
> 
> Fixes: df25461119d9 ("PCI: switchtec: Fix stdev_release() crash after surprise hot remove")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Applied to pci/switchtec for v6.9, thanks!

> ---
>  drivers/pci/switch/switchtec.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
> index 1804794d0e68..5a4adf6c04cf 100644
> --- a/drivers/pci/switch/switchtec.c
> +++ b/drivers/pci/switch/switchtec.c
> @@ -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);
> -- 
> 2.34.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-02-08 21:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-24 14:30 [PATCH] PCI: switchtec: Fix an error handling path in switchtec_pci_probe() Christophe JAILLET
2023-12-28 23:56 ` Bjorn Helgaas
2023-12-29  1:39   ` Daniel Stodden
2024-02-08 21:36 ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox