Skip to contentSkip to conversation

tty: serial: 8250: add missing pci_dev_put() before return

PATCH In review Qing Wang 3 participants 4 messages Feb 15, 2022

Subsystems (2)
lore
Share & tools
lore

Qing Wang

author
#0 lore raw

PATCH 1/1 tty: serial: 8250: add missing pci_dev_put() before return

From: Wang Qing <[email protected]>

pci_get_slot() increases its reference count, the caller must decrement the reference count by calling pci_dev_put()

---
 drivers/tty/serial/8250/8250_lpss.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/tty/serial/8250/8250_lpss.c +2 -0
index d3bafec..57e462f
@@ -149,6 +149,8 @@ static int byt_serial_setup(struct lpss8250 *lpss, struct uart_port *port)
 	/* Disable TX counter interrupts */
 	writel(BYT_TX_OVF_INT_MASK, port->membase + BYT_TX_OVF_INT);
 
+	pci_dev_put(dma_dev);
+
 	return 0;
 }
 
Signature · 1 line
2.7.4
maintainer
#1 lore raw
Quoted 15 lines · Qing Wang

From: Wang Qing <[email protected]>

pci_get_slot() increases its reference count, the caller must decrement the reference count by calling pci_dev_put()

---
  drivers/tty/serial/8250/8250_lpss.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/tty/serial/8250/8250_lpss.c +0 -0
index d3bafec..57e462f

drivers/tty/serial/8250/8250_lpss.c static int byt_serial_setup(struct lpss8250 *lpss, struct uart_port *port) · line 152

Quoted 4 lines
drivers/tty/serial/8250/8250_lpss.c +1 -0
@@ -149,6 +149,8 @@ static int byt_serial_setup(struct lpss8250 *lpss, struct uart_port *port)
  	/* Disable TX counter interrupts */
  	writel(BYT_TX_OVF_INT_MASK, port->membase + BYT_TX_OVF_INT);
 
+	pci_dev_put(dma_dev);

What about the "return -ENODEV" few lines above?

Quoted 3 lines
drivers/tty/serial/8250/8250_lpss.c +0 -0
  	return 0;
  }
 
Signature · 2 lines
js
suse labs
maintainer
#2 lore raw
Quoted 11 lines · Jiri Slaby
Quoted 10 lines · Qing Wang

From: Wang Qing <[email protected]>

pci_get_slot() increases its reference count, the caller must decrement the reference count by calling pci_dev_put()

---
  drivers/tty/serial/8250/8250_lpss.c | 2 ++

  1 file changed, 2 insertions(+)
Quoted 12 lines

drivers/tty/serial/8250/8250_lpss.c static int byt_serial_setup(struct lpss8250 *lpss, · line 152

Quoted 9 lines
drivers/tty/serial/8250/8250_lpss.c +1 -0
index d3bafec..57e462f
@@ -149,6 +149,8 @@ static int byt_serial_setup(struct lpss8250 *lpss, 
 struct uart_port *port)
       /* Disable TX counter interrupts */
       writel(BYT_TX_OVF_INT_MASK, port->membase + BYT_TX_OVF_INT);
+    pci_dev_put(dma_dev);

What about the "return -ENODEV" few lines above?

On the top of that, the code stores the pointer to the dev:
param->dma_dev = &dma_dev->dev;

So we should likely put the device in ->exit(), not ->setup().

thanks,

Signature · 2 lines
js
suse labs
#3 lore raw
Quoted 6 lines · Jiri Slaby
Quoted 5 lines · Jiri Slaby
Quoted 4 lines · Qing Wang

From: Wang Qing <[email protected]>

pci_get_slot() increases its reference count, the caller must decrement the reference count by calling pci_dev_put()

Wang, thank you for the report!

...

Quoted 6 lines
Quoted 1 line

What about the "return -ENODEV" few lines above?

On the top of that, the code stores the pointer to the dev:
param->dma_dev = &dma_dev->dev;

So we should likely put the device in ->exit(), not ->setup().

I think I may fix all these and send a new version.

Signature · 2 lines
With Best Regards,
Andy Shevchenko