Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2526350pxf; Sun, 14 Mar 2021 01:42:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJyZMepT/DL5ukP8tPC+2CUnMtTIKfLiLHzb/1xfARguohICyXIHbyStj1PaxePCVfrKDReX X-Received: by 2002:a17:906:86c1:: with SMTP id j1mr18422609ejy.373.1615714957261; Sun, 14 Mar 2021 01:42:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615714957; cv=none; d=google.com; s=arc-20160816; b=WUEFZ3l8yOOxYEg2zw/CXx+Ff65FNtrPZ4iJGudvvcPdL2uZSNjpPnOhkZ6wRmRshj OmTA+/OXNHu/xowuUtnOF6Afrf5/i6EemC+4eqJUR84WfpFZ2sLfSpsyolke6X3kRgeW JtKvLDH20noH2MuI1Sth4qZItMNrV/7CL/huKphX+TYvYI29VF/eKI8iPwGq73FCZ069 b8l402ckEgkEAKadlbkcK+gB6qMeXuT3JQk3xFFnoFFsZAczZYXVNULIZGlfR8TzhWmo h1wBb5OtNiLCD9HFq7PtoVeKpbV2OLzbJAQW/gFtMmgneGWc47/JqB69KlDFpmIJzl9C cC1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:references:cc :to:from:subject; bh=zS8OhtBxhw2WI2aamD9/HlfQgxSEWeAXGkqzrRUaFKY=; b=Kuhq4uuPTnExS9ibRr6kWuJrnAXDWaePlaaLRbMAi/H68A1JACgPhrhojD9oJW0caN 3LlMvHDYASbc7sTmHDS1FiALLINOm3952pRi496FoM6gSg0m8jvA2CHJ7qCCILoLdneL TWXQ+SuQj0e/GL+wcja8Y46wKgsn78OYYqSWr3oOp2UpVYipVtWXMV0xPXG4PoJ50CEd 8X3B7BiEdsRbNjTlKRpCapYxM6P1BToXPdjiFqV99wkE+szwGKEhWUTtw7zU4qUXIzeb YmEvKu29LoPEammB2Y1LHq5r2+4OcNEXTWzO2XZCToFLT7d+DrC3GaVScUeX5J9zP16b JfEg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sb16si8576207ejb.715.2021.03.14.01.42.15; Sun, 14 Mar 2021 01:42:37 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235029AbhCNJlV (ORCPT + 99 others); Sun, 14 Mar 2021 05:41:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230265AbhCNJki (ORCPT ); Sun, 14 Mar 2021 05:40:38 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA1ADC061574 for ; Sun, 14 Mar 2021 01:40:37 -0800 (PST) Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=[IPv6:::1]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1lLNEb-0000iR-MW; Sun, 14 Mar 2021 10:40:29 +0100 Subject: Re: [PATCH V4] clk: imx: Fix reparenting of UARTs not associated with stdout From: Ahmad Fatoum To: Adam Ford , linux-clk@vger.kernel.org Cc: Aisheng Dong , Linus Walleij , Abel Vesa , Stephen Boyd , Fabio Estevam , Michael Turquette , aford@beaconembedded.com, linux-kernel@vger.kernel.org, NXP Linux Team , Pengutronix Kernel Team , Shawn Guo , Sascha Hauer , linux-arm-kernel@lists.infradead.org, Jerome Brunet References: <20210313122818.445228-1-aford173@gmail.com> Message-ID: <0361ab5b-a26e-7631-9bae-8909715f6354@pengutronix.de> Date: Sun, 14 Mar 2021 10:40:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: a.fatoum@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13.03.21 16:16, Ahmad Fatoum wrote: >> +/* i.MX boards use device trees now. For build tests without CONFIG_OF, do nothing */ >> +#ifdef CONFIG_OF >> if (imx_keep_uart_clocks) { >> int i; >> >> - imx_uart_clocks = clks; >> - for (i = 0; imx_uart_clocks[i]; i++) >> - clk_prepare_enable(*imx_uart_clocks[i]); >> + imx_uart_clocks = kcalloc(clk_count, sizeof(struct clk *), GFP_KERNEL); >> + >> + if (!of_stdout) >> + return; > > Memory leak. Just do if (imx_keep_uart_clocks && of_stdout) Please dismiss. I overlooked that you free it in a later initcall. >> static int __init imx_clk_disable_uart(void) >> { >> - if (imx_keep_uart_clocks && imx_uart_clocks) { >> + if (imx_keep_uart_clocks && imx_enabled_uart_clocks) { >> int i; >> >> - for (i = 0; imx_uart_clocks[i]; i++) >> - clk_disable_unprepare(*imx_uart_clocks[i]); >> + for (i = 0; i < imx_enabled_uart_clocks; i++) { >> + clk_disable_unprepare(imx_uart_clocks[i]); >> + clk_put(imx_uart_clocks[i]); >> + }; >> + kfree(imx_uart_clocks); >> } -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |