Skip to content

Commit ca7c22f

Browse files
khoroshilovgregkh
authored andcommitted
serial: mxs-auart: disable clks of Alphascale ASM9260
In case of Alphascale ASM9260 probe() enables s->clk and s->clk_ahb via mxs_get_clks(), but there is no disable of the clocks. The patch adds it to error paths and to mxs_auart_remove(). Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov <[email protected]> Fixes: 254da0d ("serial: mxs-auart: add Alphascale ASM9260 support") Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7d6e214 commit ca7c22f

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

drivers/tty/serial/mxs-auart.c

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,8 +1678,10 @@ static int mxs_auart_probe(struct platform_device *pdev)
16781678
return ret;
16791679

16801680
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1681-
if (!r)
1682-
return -ENXIO;
1681+
if (!r) {
1682+
ret = -ENXIO;
1683+
goto out_disable_clks;
1684+
}
16831685

16841686
s->port.mapbase = r->start;
16851687
s->port.membase = ioremap(r->start, resource_size(r));
@@ -1694,37 +1696,39 @@ static int mxs_auart_probe(struct platform_device *pdev)
16941696
s->mctrl_prev = 0;
16951697

16961698
irq = platform_get_irq(pdev, 0);
1697-
if (irq < 0)
1698-
return irq;
1699+
if (irq < 0) {
1700+
ret = irq;
1701+
goto out_disable_clks;
1702+
}
16991703

17001704
s->port.irq = irq;
17011705
ret = devm_request_irq(&pdev->dev, irq, mxs_auart_irq_handle, 0,
17021706
dev_name(&pdev->dev), s);
17031707
if (ret)
1704-
return ret;
1708+
goto out_disable_clks;
17051709

17061710
platform_set_drvdata(pdev, s);
17071711

17081712
ret = mxs_auart_init_gpios(s, &pdev->dev);
17091713
if (ret) {
17101714
dev_err(&pdev->dev, "Failed to initialize GPIOs.\n");
1711-
return ret;
1715+
goto out_disable_clks;
17121716
}
17131717

17141718
/*
17151719
* Get the GPIO lines IRQ
17161720
*/
17171721
ret = mxs_auart_request_gpio_irq(s);
17181722
if (ret)
1719-
return ret;
1723+
goto out_disable_clks;
17201724

17211725
auart_port[s->port.line] = s;
17221726

17231727
mxs_auart_reset_deassert(s);
17241728

17251729
ret = uart_add_one_port(&auart_driver, &s->port);
17261730
if (ret)
1727-
goto out_disable_clks_free_qpio_irq;
1731+
goto out_free_qpio_irq;
17281732

17291733
/* ASM9260 don't have version reg */
17301734
if (is_asm9260_auart(s)) {
@@ -1738,13 +1742,15 @@ static int mxs_auart_probe(struct platform_device *pdev)
17381742

17391743
return 0;
17401744

1741-
out_disable_clks_free_qpio_irq:
1742-
if (s->clk)
1743-
clk_disable_unprepare(s->clk_ahb);
1744-
if (s->clk_ahb)
1745-
clk_disable_unprepare(s->clk_ahb);
1745+
out_free_qpio_irq:
17461746
mxs_auart_free_gpio_irq(s);
17471747
auart_port[pdev->id] = NULL;
1748+
1749+
out_disable_clks:
1750+
if (is_asm9260_auart(s)) {
1751+
clk_disable_unprepare(s->clk);
1752+
clk_disable_unprepare(s->clk_ahb);
1753+
}
17481754
return ret;
17491755
}
17501756

@@ -1755,6 +1761,10 @@ static int mxs_auart_remove(struct platform_device *pdev)
17551761
uart_remove_one_port(&auart_driver, &s->port);
17561762
auart_port[pdev->id] = NULL;
17571763
mxs_auart_free_gpio_irq(s);
1764+
if (is_asm9260_auart(s)) {
1765+
clk_disable_unprepare(s->clk);
1766+
clk_disable_unprepare(s->clk_ahb);
1767+
}
17581768

17591769
return 0;
17601770
}

0 commit comments

Comments
 (0)