diff mbox series

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

Message ID 1644890454-65258-1-git-send-email-wangqing@vivo.com
State New
Headers show
Series tty: serial: 8250: add missing pci_dev_put() before return | expand

Commit Message

Qing Wang Feb. 15, 2022, 2 a.m. UTC
From: Wang Qing <wangqing@vivo.com>

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

Signed-off-by: Wang Qing <wangqing@vivo.com>
---
 drivers/tty/serial/8250/8250_lpss.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Jiri Slaby Feb. 15, 2022, 6:02 a.m. UTC | #1
On 15. 02. 22, 6:55, Jiri Slaby wrote:
> On 15. 02. 22, 3:00, Qing Wang wrote:
>> From: Wang Qing <wangqing@vivo.com>
>>
>> pci_get_slot() increases its reference count, the caller must
>> decrement the reference count by calling pci_dev_put()
>>
>> Signed-off-by: Wang Qing <wangqing@vivo.com>
>> ---
>>   drivers/tty/serial/8250/8250_lpss.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/tty/serial/8250/8250_lpss.c 
>> b/drivers/tty/serial/8250/8250_lpss.c
>> index d3bafec..57e462f
>> --- a/drivers/tty/serial/8250/8250_lpss.c
>> +++ b/drivers/tty/serial/8250/8250_lpss.c
>> @@ -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,
diff mbox series

Patch

diff --git a/drivers/tty/serial/8250/8250_lpss.c b/drivers/tty/serial/8250/8250_lpss.c
index d3bafec..57e462f
--- a/drivers/tty/serial/8250/8250_lpss.c
+++ b/drivers/tty/serial/8250/8250_lpss.c
@@ -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;
 }