Skip to content

Commit

Permalink
serial: 8250_mid: Balance reference count for PCI DMA device
Browse files Browse the repository at this point in the history
[ Upstream commit 67ec6dd ]

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

Fixes: 90b9aac ("serial: 8250_pci: add Intel Tangier support")
Fixes: f549e94 ("serial: 8250_pci: add Intel Penwell ports")
Reported-by: Qing Wang <wangqing@vivo.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Depends-on: d9eda9b ("serial: 8250_pci: Intel MID UART support to its own driver")
Link: https://lore.kernel.org/r/20220215100920.41984-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
andy-shev authored and gregkh committed Apr 8, 2022
1 parent 12e4a92 commit 2bab56f
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions drivers/tty/serial/8250/8250_mid.c
Expand Up @@ -73,6 +73,11 @@ static int pnw_setup(struct mid8250 *mid, struct uart_port *p)
return 0;
}

static void pnw_exit(struct mid8250 *mid)
{
pci_dev_put(mid->dma_dev);
}

static int tng_handle_irq(struct uart_port *p)
{
struct mid8250 *mid = p->private_data;
Expand Down Expand Up @@ -124,6 +129,11 @@ static int tng_setup(struct mid8250 *mid, struct uart_port *p)
return 0;
}

static void tng_exit(struct mid8250 *mid)
{
pci_dev_put(mid->dma_dev);
}

static int dnv_handle_irq(struct uart_port *p)
{
struct mid8250 *mid = p->private_data;
Expand Down Expand Up @@ -330,9 +340,9 @@ static int mid8250_probe(struct pci_dev *pdev, const struct pci_device_id *id)

pci_set_drvdata(pdev, mid);
return 0;

err:
if (mid->board->exit)
mid->board->exit(mid);
mid->board->exit(mid);
return ret;
}

Expand All @@ -342,22 +352,23 @@ static void mid8250_remove(struct pci_dev *pdev)

serial8250_unregister_port(mid->line);

if (mid->board->exit)
mid->board->exit(mid);
mid->board->exit(mid);
}

static const struct mid8250_board pnw_board = {
.flags = FL_BASE0,
.freq = 50000000,
.base_baud = 115200,
.setup = pnw_setup,
.exit = pnw_exit,
};

static const struct mid8250_board tng_board = {
.flags = FL_BASE0,
.freq = 38400000,
.base_baud = 1843200,
.setup = tng_setup,
.exit = tng_exit,
};

static const struct mid8250_board dnv_board = {
Expand Down

0 comments on commit 2bab56f

Please sign in to comment.