Skip to content

Commit 31697ef

Browse files
damien-lemoalLinus Walleij
authored andcommitted
pinctrl: k210: Fix k210_fpioa_probe()
In k210_fpioa_probe(), add missing calls to clk_disable_unprepare() in case of error after cenabling the clk and pclk clocks. Also add missing error handling when enabling pclk. Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Fixes: d4c34d0 ("pinctrl: Add RISC-V Canaan Kendryte K210 FPIOA driver") Cc: <stable@vger.kernel.org> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> Link: https://lore.kernel.org/r/20210806004311.52859-1-damien.lemoal@wdc.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent d1dee81 commit 31697ef

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

drivers/pinctrl/pinctrl-k210.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -950,23 +950,37 @@ static int k210_fpioa_probe(struct platform_device *pdev)
950950
return ret;
951951

952952
pdata->pclk = devm_clk_get_optional(dev, "pclk");
953-
if (!IS_ERR(pdata->pclk))
954-
clk_prepare_enable(pdata->pclk);
953+
if (!IS_ERR(pdata->pclk)) {
954+
ret = clk_prepare_enable(pdata->pclk);
955+
if (ret)
956+
goto disable_clk;
957+
}
955958

956959
pdata->sysctl_map =
957960
syscon_regmap_lookup_by_phandle_args(np,
958961
"canaan,k210-sysctl-power",
959962
1, &pdata->power_offset);
960-
if (IS_ERR(pdata->sysctl_map))
961-
return PTR_ERR(pdata->sysctl_map);
963+
if (IS_ERR(pdata->sysctl_map)) {
964+
ret = PTR_ERR(pdata->sysctl_map);
965+
goto disable_pclk;
966+
}
962967

963968
k210_fpioa_init_ties(pdata);
964969

965970
pdata->pctl = pinctrl_register(&k210_pinctrl_desc, dev, (void *)pdata);
966-
if (IS_ERR(pdata->pctl))
967-
return PTR_ERR(pdata->pctl);
971+
if (IS_ERR(pdata->pctl)) {
972+
ret = PTR_ERR(pdata->pctl);
973+
goto disable_pclk;
974+
}
968975

969976
return 0;
977+
978+
disable_pclk:
979+
clk_disable_unprepare(pdata->pclk);
980+
disable_clk:
981+
clk_disable_unprepare(pdata->clk);
982+
983+
return ret;
970984
}
971985

972986
static const struct of_device_id k210_fpioa_dt_ids[] = {

0 commit comments

Comments
 (0)