linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] serial: 8250_exar: Add missing call to pci_free_irq_vectors()
@ 2021-08-17 17:00 Utkarsh Verma
  2021-08-17 17:31 ` Andy Shevchenko
  2021-08-17 17:38 ` Andy Shevchenko
  0 siblings, 2 replies; 3+ messages in thread
From: Utkarsh Verma @ 2021-08-17 17:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, Andy Shevchenko, Heikki Krogerus, Valmer Huhn,
	linux-serial, linux-kernel, linux-kernel-mentees, Utkarsh Verma

Free the pci irq vectors if the call to pci_alloc_irq_vectors() fails
or if the device is removed.

Signed-off-by: Utkarsh Verma <utkarshverma294@gmail.com>
---
 drivers/tty/serial/8250/8250_exar.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
index 3ffeedc29c83..38b65d6980f5 100644
--- a/drivers/tty/serial/8250/8250_exar.c
+++ b/drivers/tty/serial/8250/8250_exar.c
@@ -627,8 +627,10 @@ exar_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
 	pci_set_master(pcidev);
 
 	rc = pci_alloc_irq_vectors(pcidev, 1, 1, PCI_IRQ_ALL_TYPES);
-	if (rc < 0)
+	if (rc < 0) {
+		pci_free_irq_vectors(pcidev);
 		return rc;
+	}
 
 	memset(&uart, 0, sizeof(uart));
 	uart.port.flags = UPF_SHARE_IRQ | UPF_EXAR_EFR | UPF_FIXED_TYPE | UPF_FIXED_PORT;
@@ -677,6 +679,7 @@ static void exar_pci_remove(struct pci_dev *pcidev)
 
 	if (priv->board->exit)
 		priv->board->exit(pcidev);
+	pci_free_irq_vectors(pcidev);
 }
 
 static int __maybe_unused exar_suspend(struct device *dev)
-- 
2.17.1


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

* Re: [PATCH] serial: 8250_exar: Add missing call to pci_free_irq_vectors()
  2021-08-17 17:00 [PATCH] serial: 8250_exar: Add missing call to pci_free_irq_vectors() Utkarsh Verma
@ 2021-08-17 17:31 ` Andy Shevchenko
  2021-08-17 17:38 ` Andy Shevchenko
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2021-08-17 17:31 UTC (permalink / raw)
  To: Utkarsh Verma
  Cc: Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko, Heikki Krogerus,
	Valmer Huhn, open list:SERIAL DRIVERS, Linux Kernel Mailing List,
	linux-kernel-mentees, Bjorn Helgaas

On Tue, Aug 17, 2021 at 8:05 PM Utkarsh Verma <utkarshverma294@gmail.com> wrote:
>
> Free the pci irq vectors if the call to pci_alloc_irq_vectors() fails
> or if the device is removed.

+Cc: Bjorn

This patch adds no value for all the code. This needs simply better
semantics on allocations (because freeing is happening here
implicitly).
Bjorn, this is an exact example why we need pcim_alloc_irq_vectors().

> Signed-off-by: Utkarsh Verma <utkarshverma294@gmail.com>
> ---
>  drivers/tty/serial/8250/8250_exar.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
> index 3ffeedc29c83..38b65d6980f5 100644
> --- a/drivers/tty/serial/8250/8250_exar.c
> +++ b/drivers/tty/serial/8250/8250_exar.c
> @@ -627,8 +627,10 @@ exar_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
>         pci_set_master(pcidev);
>
>         rc = pci_alloc_irq_vectors(pcidev, 1, 1, PCI_IRQ_ALL_TYPES);
> -       if (rc < 0)
> +       if (rc < 0) {
> +               pci_free_irq_vectors(pcidev);
>                 return rc;
> +       }
>
>         memset(&uart, 0, sizeof(uart));
>         uart.port.flags = UPF_SHARE_IRQ | UPF_EXAR_EFR | UPF_FIXED_TYPE | UPF_FIXED_PORT;
> @@ -677,6 +679,7 @@ static void exar_pci_remove(struct pci_dev *pcidev)
>
>         if (priv->board->exit)
>                 priv->board->exit(pcidev);
> +       pci_free_irq_vectors(pcidev);
>  }


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH] serial: 8250_exar: Add missing call to pci_free_irq_vectors()
  2021-08-17 17:00 [PATCH] serial: 8250_exar: Add missing call to pci_free_irq_vectors() Utkarsh Verma
  2021-08-17 17:31 ` Andy Shevchenko
@ 2021-08-17 17:38 ` Andy Shevchenko
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2021-08-17 17:38 UTC (permalink / raw)
  To: Utkarsh Verma
  Cc: Greg Kroah-Hartman, Jiri Slaby, Heikki Krogerus, Valmer Huhn,
	linux-serial, linux-kernel, linux-kernel-mentees

On Tue, Aug 17, 2021 at 10:30:57PM +0530, Utkarsh Verma wrote:
> Free the pci irq vectors if the call to pci_alloc_irq_vectors() fails
> or if the device is removed.

...

>  	rc = pci_alloc_irq_vectors(pcidev, 1, 1, PCI_IRQ_ALL_TYPES);
> -	if (rc < 0)
> +	if (rc < 0) {

> +		pci_free_irq_vectors(pcidev);

Why?

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2021-08-17 17:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-17 17:00 [PATCH] serial: 8250_exar: Add missing call to pci_free_irq_vectors() Utkarsh Verma
2021-08-17 17:31 ` Andy Shevchenko
2021-08-17 17:38 ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).