From patchwork Mon May 18 17:37:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 225774 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B78A3C433E0 for ; Mon, 18 May 2020 17:58:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 90D7820829 for ; Mon, 18 May 2020 17:58:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589824739; bh=pa+G38MI220nHFy8k4su+iNcYpvxDIJDPuNMLH5TxK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=0A7qoOOj6iuPNHtaOYpk/se99uNdOaUXySHw+I0ct5bTEmr2CcPPvXU7eihYJUT3G O1RwqR26LR1yEtNmz+wmEP3qhwEuVseIU6/x95jyKUOCI8/OAYI1qreTPOznghM6bW qaPhdCWf4Ynbbo1VBwhcVawBv9/65c5d5HKQI4no= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731542AbgERR66 (ORCPT ); Mon, 18 May 2020 13:58:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:38832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731953AbgERR65 (ORCPT ); Mon, 18 May 2020 13:58:57 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A926D20715; Mon, 18 May 2020 17:58:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589824737; bh=pa+G38MI220nHFy8k4su+iNcYpvxDIJDPuNMLH5TxK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i6JIzJ5n3d4t973eTRh6GLa7aDvq8UCIe6JMR4eMGjXKQF3Jpye2nBJFu64ObmW4G fEHOn9CtddX3NpPHGa6sR39xnPkDLx2Z01ZFp/JQRftp5633pZIqyhZ0pcsnTNofxB BXQ/VD/FJeZt6nT+yQHh16F7G0fqJPXTxPIsXwmQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier , Guenter Roeck , Stephen Boyd , Michael Turquette Subject: [PATCH 5.4 132/147] clk: Unlink clock if failed to prepare or enable Date: Mon, 18 May 2020 19:37:35 +0200 Message-Id: <20200518173529.807007387@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200518173513.009514388@linuxfoundation.org> References: <20200518173513.009514388@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marc Zyngier commit 018d4671b9bbd4a5c55cf6eab3e1dbc70a50b66e upstream. On failing to prepare or enable a clock, remove the core structure from the list it has been inserted as it is about to be freed. This otherwise leads to random crashes when subsequent clocks get registered, during which parsing of the clock tree becomes adventurous. Observed with QEMU's RPi-3 emulation. Fixes: 12ead77432f2 ("clk: Don't try to enable critical clocks if prepare failed") Signed-off-by: Marc Zyngier Cc: Guenter Roeck Cc: Stephen Boyd Cc: Michael Turquette Link: https://lkml.kernel.org/r/20200505140953.409430-1-maz@kernel.org Signed-off-by: Stephen Boyd Signed-off-by: Greg Kroah-Hartman --- drivers/clk/clk.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -3448,6 +3448,9 @@ static int __clk_core_init(struct clk_co out: clk_pm_runtime_put(core); unlock: + if (ret) + hlist_del_init(&core->child_node); + clk_prepare_unlock(); if (!ret)