serial: 8250_exar: Add missing call to pci_free_irq_vectors()
PATCH 1/1 serial: 8250_exar: Add missing call to pci_free_irq_vectors()
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 <[email protected]>
--- drivers/tty/serial/8250/8250_exar.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/tty/serial/8250/8250_exar.c +4 -1
@@ -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)
Signature · 1 line
2.17.1
Quoted 3 lines · Utkarsh Verma
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().
Quoted 27 lines
Signed-off-by Utkarsh Verma <[email protected]>--- drivers/tty/serial/8250/8250_exar.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/tty/serial/8250/8250_exar.c +4
-1@@ -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); }
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 2 lines · Utkarsh Verma
Free the pci irq vectors if the call to
pci_alloc_irq_vectors()fails or if the device is removed.
...
drivers/tty/serial/8250/8250_exar.c exar_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
Quoted 5 lines
drivers/tty/serial/8250/8250_exar.c +2
-1rc =pci_alloc_irq_vectors (pcidev,1 ,1 ,PCI_IRQ_ALL_TYPES ); -if (rc <0 ) +if (rc <0 ) { +pci_free_irq_vectors (pcidev);
Why?
Signature · 8 lines
With Best Regards, Andy Shevchenko _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees