From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E45B8494 for ; Thu, 5 Jan 2023 13:01:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9409C433EF; Thu, 5 Jan 2023 13:01:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672923675; bh=VjMIT4Ez8Pg5JYazinZ/NzJEyK/6XD/Xx3uN4REvwmg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AgyYVW4aoH0BYiu01f+Nl+/fZgXE/PXk1TwyvAs9QWfLRO489L8OY49BhWqlNAtbE Z7t7b41IAobKqnl0fRYpZTgVSi/pPPPJMmTKlGmMQRTf/SV2zUcO5so2UpAVLMTXAz Xbach3wzpPYK6qg5Yyyr3iTTrBs8jsQy3zhDs3hM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Xiu Jianfeng , Heiko Stuebner , Sasha Levin Subject: [PATCH 4.9 066/251] clk: rockchip: Fix memory leak in rockchip_clk_register_pll() Date: Thu, 5 Jan 2023 13:53:23 +0100 Message-Id: <20230105125337.780692108@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230105125334.727282894@linuxfoundation.org> References: <20230105125334.727282894@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Xiu Jianfeng [ Upstream commit 739a6a6bbdb793bd57938cb24aa5a6df89983546 ] If clk_register() fails, @pll->rate_table may have allocated memory by kmemdup(), so it needs to be freed, otherwise will cause memory leak issue, this patch fixes it. Fixes: 90c590254051 ("clk: rockchip: add clock type for pll clocks and pll used on rk3066") Signed-off-by: Xiu Jianfeng Link: https://lore.kernel.org/r/20221123091201.199819-1-xiujianfeng@huawei.com Signed-off-by: Heiko Stuebner Signed-off-by: Sasha Levin --- drivers/clk/rockchip/clk-pll.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/clk/rockchip/clk-pll.c b/drivers/clk/rockchip/clk-pll.c index 9c1373e81683..347d659c8f34 100644 --- a/drivers/clk/rockchip/clk-pll.c +++ b/drivers/clk/rockchip/clk-pll.c @@ -957,6 +957,7 @@ struct clk *rockchip_clk_register_pll(struct rockchip_clk_provider *ctx, return mux_clk; err_pll: + kfree(pll->rate_table); clk_unregister(mux_clk); mux_clk = pll_clk; err_mux: -- 2.35.1