Re: [Patch] serial: 8250_bcm7271: fix leak in `brcmuart_probe`

From: Greg Kroah-Hartman
Date: Sat May 13 2023 - 06:32:09 EST


On Mon, Apr 24, 2023 at 08:51:00PM +0800, XuDong Liu wrote:
> Smatch reports:
> drivers/tty/serial/8250/8250_bcm7271.c:1120 brcmuart_probe() warn:
> 'baud_mux_clk' from clk_prepare_enable() not released on lines: 1032.
>
> In the function brcmuart_probe(), baud_mux_clk was not correctly released
> in subsequent error handling, which may cause memory leaks.
>
> To fix this issue, an error handling branch, err_clk_put, is added to
> release the variable using clk_put(), and an err_disable branch is added
> to meet the requirement of balancing clk_disable and clk_enable calls.
>
> Fixes: 15ac1122fd6d ("serial: 8250_bcm7271: Fix arbitration handling")
> Signed-off-by: XuDong Liu <m202071377@xxxxxxxxxxx>
> Reviewed-by: Dongliang Mu <dzm91@xxxxxxxxxxx>
> ---
> The issue is discovered by static analysis, and the patch is not tested
> yet.

Please test it.

thanks,

greg k-h