Re: [PATCH v2] ata: sata_mv: aspeed: fix value check in mv_platform_probe()

From: Damien Le Moal
Date: Mon Oct 09 2023 - 18:34:08 EST


On 10/9/23 21:49, Ma Ke wrote:
> In mv_platform_probe(), check the return value of clk_prepare_enable()
> and return the error code if clk_prepare_enable() returns an
> unexpected value.
>
> Signed-off-by: Ma Ke <make_ruc2021@xxxxxxx>
> ---
> drivers/ata/sata_mv.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
> index 45e48d653c60..df3a02e7a50b 100644
> --- a/drivers/ata/sata_mv.c
> +++ b/drivers/ata/sata_mv.c
> @@ -4125,8 +4125,10 @@ static int mv_platform_probe(struct platform_device *pdev)
> hpriv->clk = clk_get(&pdev->dev, NULL);
> if (IS_ERR(hpriv->clk))
> dev_notice(&pdev->dev, "cannot get optional clkdev\n");
> - else
> - clk_prepare_enable(hpriv->clk);
> + else {
> + rc = clk_prepare_enable(hpriv->clk);
> + goto err;

This is wrong. The goto err should only be done if there is an error.
Did you even test your own patch ???

> + }
>
> for (port = 0; port < n_ports; port++) {
> char port_number[16];

--
Damien Le Moal
Western Digital Research