Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751472AbdFHLsO (ORCPT ); Thu, 8 Jun 2017 07:48:14 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:35134 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751392AbdFHLsN (ORCPT ); Thu, 8 Jun 2017 07:48:13 -0400 From: Arvind Yadav To: a.zummo@towertech.it, alexandre.belloni@free-electrons.com Cc: rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org Subject: [PATCH] rtc: omap: Handle return value of clk_prepare_enable. Date: Thu, 8 Jun 2017 17:17:49 +0530 Message-Id: <7bfcac1de9426c3e512a61922bca4239f8b520b5.1496922334.git.arvind.yadav.cs@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1613 Lines: 57 - clk_prepare_enable() can fail here and we must check its return value. - Add missing clk_disable_unprepare(), if omap_rtc_probe is not successful. Signed-off-by: Arvind Yadav --- drivers/rtc/rtc-omap.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index 13f7cd1..83b876d 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c @@ -705,13 +705,19 @@ static int omap_rtc_probe(struct platform_device *pdev) else rtc->clk = devm_clk_get(&pdev->dev, "int-clk"); - if (!IS_ERR(rtc->clk)) - clk_prepare_enable(rtc->clk); + if (IS_ERR(rtc->clk)) + return PTR_ERR(rtc->clk); + + ret = clk_prepare_enable(rtc->clk); + if (ret) + return ret; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); rtc->base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(rtc->base)) - return PTR_ERR(rtc->base); + if (IS_ERR(rtc->base)) { + ret = PTR_ERR(rtc->base); + goto err_clk; + } platform_set_drvdata(pdev, rtc); @@ -830,7 +836,8 @@ static int omap_rtc_probe(struct platform_device *pdev) rtc->pctldev = pinctrl_register(&rtc_pinctrl_desc, &pdev->dev, rtc); if (IS_ERR(rtc->pctldev)) { dev_err(&pdev->dev, "Couldn't register pinctrl driver\n"); - return PTR_ERR(rtc->pctldev); + ret = PTR_ERR(rtc->pctldev); + goto err; } return 0; @@ -841,6 +848,8 @@ static int omap_rtc_probe(struct platform_device *pdev) pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); +err_clk: + clk_disable_unprepare(rtc->clk); return ret; } -- 1.9.1