From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3168CC44501 for ; Thu, 9 Jul 2026 12:37:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=kGgN2/HFGqb9sJPIBobkAavwHd6m6iCcZaCrbIb56A4=; b=lC/mGZUceVuU+pvcscojk2jsa9 P0Oe7+SsOKRHDp0JMLqVuGeJ1xRsaz1eHnb1l0kh/I0OrnbkNykbD7nSZ9AfFpLMRA10WAnso7HO7 iyBTHpu8a/gI9qQMtiId/JFCwX55Wd9h5b0t0jhYdIiLm52kGYWqPixHXiRFKL4letyAv0VbYny5B fGqDLOUqQiaowO0sltzZlfxY65Uc1K/pxPbl5rwzsz+yu0LsmLOm7ux1hmQd/iqSGt54UVc5AS5sk zAHENo0pg0AmZR+uOULS6aYo4JZfi6QSijSz7pT6vz15xe9mVN7fAS0o9sfgHKR6lOwWfkr7Bl7U2 rZxfuMTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1who0V-00000002R2r-0RvB; Thu, 09 Jul 2026 12:37:35 +0000 Received: from bali.collaboradmins.com ([148.251.105.195]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1who0Q-00000002R1O-3U5u; Thu, 09 Jul 2026 12:37:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1783600648; bh=8yyJEbIHI2mkuZBKd8+eqb/esgh9Y/d8wQDBk8sgJeg=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=bILNGBKVnYxOwqyfBhm9l4O+SEleUGbT1RuohSDGjgux6kPL6NhAJDnR0UE3AXNFN WD/IcfHv6DhjbOlZKc8xRe/tUzhZT54m9UTuXWrYjz8to9q3gqaczIm7KnQOBzfRbw enJvAZvVHpiEo1QjZUBlHcFo0jjzpnZXRoVBTmUFZWUHXk2MPVuiiyN2WK/uoXvBTQ FgUvLGP1fpQGZfVKKabsniJEgwUQ5fPdx6sDXMUIOUGmwxXquBnloZhnLDY9J+cT7c sLVrQxVpLITaWSYbRH3OHCW9CusnPb59BlJxIdRWlAQU06ouMyqfULUykW5D6JN4VO CBLnLflspAz0Q== Received: from [100.64.1.21] (unknown [100.64.1.21]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange x25519) (No client certificate requested) (Authenticated sender: kholk11) by bali.collaboradmins.com (Postfix) with ESMTPSA id 3284A17E079B; Thu, 09 Jul 2026 14:37:28 +0200 (CEST) Message-ID: Date: Thu, 9 Jul 2026 14:37:27 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] clk: mediatek: pllfh: Fix IO remapping leak in register_pllfhs error path To: Louis-Alexis Eyraud , Michael Turquette , Stephen Boyd , Brian Masney , Matthias Brugger , Chen-Yu Tsai , Edward-JW Yang , Johnson Wang Cc: kernel@collabora.com, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org References: <20260709-clk-mediatek-pllfh-fix-v2-1-a235078fe9d5@collabora.com> From: AngeloGioacchino Del Regno Content-Language: en-US In-Reply-To: <20260709-clk-mediatek-pllfh-fix-v2-1-a235078fe9d5@collabora.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260709_053731_020965_DD2A90E0 X-CRM114-Status: GOOD ( 12.45 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org On 7/9/26 14:23, Louis-Alexis Eyraud wrote: > When mtk_clk_register_pllfhs function fails to register a PLL, it > unregisters all PLLs and cleans up itself in its error path before > returning, so the function callers don't need to do it. > > But contrary to mtk_clk_unregister_pllfhs function, that does almost > the same sequence, it does not free the IO memory mapped on fhctl node, > leading to a leak. > > Fix this leak by factorizing the cleanup sequence in a new private > function and use it both mtk_clk_register_pllfhs and > mtk_clk_unregister_pllfhs functions. > > Also, change the loop index start value to avoid the -1 operation on > index at each loop. > > Fixes: d7964de8a8ea ("clk: mediatek: Add new clock driver to handle FHCTL hardware") > Signed-off-by: Louis-Alexis Eyraud Reviewed-by: AngeloGioacchino Del Regno