Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2718326pxv; Sun, 11 Jul 2021 23:42:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrP3fKxZC+cuioNDiYGXZ6G/0tDvhdR6UVs2IS5l0M8JcM/MaG16tJBx+D5+3dVD2XB2BV X-Received: by 2002:a05:6402:c17:: with SMTP id co23mr28194251edb.68.1626072148768; Sun, 11 Jul 2021 23:42:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626072148; cv=none; d=google.com; s=arc-20160816; b=Wr/5fKYHReW6Zn/EOJx6deM24fuBSiGn9U+Cv1kJeGkBEyJtHz7HdIfWdhvxFq6DUY tyS1DHA4zOp4JgYFT24YJVhp70o7frSxoa6n9kFn4OS+HA5W+eqIeAlVAUVhKucWVTTD 3CfiWmDihI8waedR87eyMbiMSLetcsbxCNx5LlPD3xtTsYPUlXUw6TCqhx+QzEP9qlzg fK2vJrlcBGfjKvqN4b2S2XuxmHiI3jiddGxWi1jltoDnReR14Eg8ezCX8twIqcMT1/Jk MiGf9rUnErbZKx7TB9wVb/wo9uUjHeRKxsE2Dmt6Zd/UfprqqhfihC2BzGD2ikJqKcT6 n+3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=d+J9AF4SSo0ilojsy51oP6maWtb+adFk2kBt1LTLYTA=; b=UHifOV0GV83/cPqaGlB60w2BoQdeWWSs/4XT8IXhuCwRXveETy1Ml5anvr1N4TwKkp iYqvPE8oQwjavkbqYZe4JH47IEXCMKney9cy2ecchbha7H53Z/J9P9Kn6bjbL9BYoSGN Akw9TgU4t7fd7LOEtNIxFY7bUFwdoS5i5Z5Y/qmWWdVxItFuu6CqNthBX19r565j0FU9 A9UetGHJ5Le0Bil+TapZbqqjXs+oi8p6PMun2mLHO/9zwccGlvFWmtteXdOTGzRu6RkH HKQAQ9W0KZ+pM8gGOpJ0wh+UGZDQ0maVdu/I7I7jo/pFvExyNw0z/hkPrFZWOHs7h1zr LmNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=16tgekHr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y6si2336868edr.409.2021.07.11.23.42.05; Sun, 11 Jul 2021 23:42:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=16tgekHr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238352AbhGLGny (ORCPT + 99 others); Mon, 12 Jul 2021 02:43:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:54054 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237252AbhGLGeO (ORCPT ); Mon, 12 Jul 2021 02:34:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3768D61178; Mon, 12 Jul 2021 06:30:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071438; bh=I+m9Xmztvswkqnx/OgxmcxrQUD42OS7yHXFVcRfIjro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=16tgekHrFKqd5sP9KzTsTumUWF554fsi7gg+hqTLfrWE2GwH+VL2ZHMXZzJB49SIB fqugzryy8jJF/A+Js27vlKophbSFH5UdBGMCq3qYYtTcPOPK01PD9uEgoKZ8G2Rfw/ 3CDRRUQpzMJA6pdOKeWvolN7df5ta6/qpVN5ci8E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Fuzzey , Nobuhiro Iwamatsu , Alexandre Belloni Subject: [PATCH 5.10 071/593] rtc: stm32: Fix unbalanced clk_disable_unprepare() on probe error path Date: Mon, 12 Jul 2021 08:03:51 +0200 Message-Id: <20210712060850.958809290@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060843.180606720@linuxfoundation.org> References: <20210712060843.180606720@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Martin Fuzzey commit 950ac33dbe6ff656a623d862022f0762ec061ba7 upstream. The STM32MP1 RTC may have 2 clocks, the pclk and the rtc_ck. If clk_prepare_enable() fails for the second clock (rtc_ck) we must only call clk_disable_unprepare() for the first clock (pclk) but currently we call it on both leading to a WARN: [ 15.629568] WARNING: CPU: 0 PID: 146 at drivers/clk/clk.c:958 clk_core_disable+0xb0/0xc8 [ 15.637620] ck_rtc already disabled [ 15.663322] CPU: 0 PID: 146 Comm: systemd-udevd Not tainted 5.4.77-pknbsp-svn5759-atag-v5.4.77-204-gea4235203137-dirty #2413 [ 15.674510] Hardware name: STM32 (Device Tree Support) [ 15.679658] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 15.687371] [] (show_stack) from [] (dump_stack+0xc0/0xe0) [ 15.694574] [] (dump_stack) from [] (__warn+0xc8/0xf0) [ 15.701428] [] (__warn) from [] (warn_slowpath_fmt+0x60/0x94) [ 15.708894] [] (warn_slowpath_fmt) from [] (clk_core_disable+0xb0/0xc8) [ 15.717230] [] (clk_core_disable) from [] (clk_core_disable_lock+0x18/0x24) [ 15.725924] [] (clk_core_disable_lock) from [] (stm32_rtc_probe+0x124/0x5e4 [rtc_stm32]) [ 15.735739] [] (stm32_rtc_probe [rtc_stm32]) from [] (platform_drv_probe+0x48/0x98) [ 15.745095] [] (platform_drv_probe) from [] (really_probe+0x1f0/0x458) [ 15.753338] [] (really_probe) from [] (driver_probe_device+0x70/0x1c4) [ 15.761584] [] (driver_probe_device) from [] (device_driver_attach+0x58/0x60) [ 15.770439] [] (device_driver_attach) from [] (__driver_attach+0xcc/0x170) [ 15.779032] [] (__driver_attach) from [] (bus_for_each_dev+0x58/0x7c) [ 15.787191] [] (bus_for_each_dev) from [] (bus_add_driver+0xdc/0x1f8) [ 15.795352] [] (bus_add_driver) from [] (driver_register+0x7c/0x110) [ 15.803425] [] (driver_register) from [] (do_one_initcall+0x70/0x1b8) [ 15.811588] [] (do_one_initcall) from [] (do_init_module+0x58/0x1f8) [ 15.819660] [] (do_init_module) from [] (load_module+0x1e58/0x23c8) [ 15.827646] [] (load_module) from [] (sys_finit_module+0xa0/0xd4) [ 15.835459] [] (sys_finit_module) from [] (__sys_trace_return+0x0/0x20) Signed-off-by: Martin Fuzzey Fixes: 4e64350f42e2 ("rtc: add STM32 RTC driver") Cc: stable@vger.kernel.org Reviewed-by: Nobuhiro Iwamatsu Signed-off-by: Alexandre Belloni Link: https://lore.kernel.org/r/1623087421-19722-1-git-send-email-martin.fuzzey@flowbird.group Signed-off-by: Greg Kroah-Hartman --- drivers/rtc/rtc-stm32.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/rtc/rtc-stm32.c +++ b/drivers/rtc/rtc-stm32.c @@ -754,7 +754,7 @@ static int stm32_rtc_probe(struct platfo ret = clk_prepare_enable(rtc->rtc_ck); if (ret) - goto err; + goto err_no_rtc_ck; if (rtc->data->need_dbp) regmap_update_bits(rtc->dbp, rtc->dbp_reg, @@ -830,10 +830,12 @@ static int stm32_rtc_probe(struct platfo } return 0; + err: + clk_disable_unprepare(rtc->rtc_ck); +err_no_rtc_ck: if (rtc->data->has_pclk) clk_disable_unprepare(rtc->pclk); - clk_disable_unprepare(rtc->rtc_ck); if (rtc->data->need_dbp) regmap_update_bits(rtc->dbp, rtc->dbp_reg, rtc->dbp_mask, 0);