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 BD5CB1863 for ; Wed, 28 Dec 2022 15:49:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43175C433D2; Wed, 28 Dec 2022 15:49:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672242573; bh=8/sVOYx2bnqClV5wMIKys2+H3FCefamDGqS5rgWovWw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uqP4txTZ1CGQwnVTn31DPDZUH5t8unxrwzexlhJusKmCHLEo1ZKgaKpahr/dKrUZ/ BkSmOplVJAL/uClgieqtxofI7xAdYUq5Pk1crCZxkrQs+YOK1jutDT19BSrtslvWJp +I0gMGXUYBHpoarG5oaGDU4W0CMTkqrorDSfY+o0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Xiu Jianfeng , Nobuhiro Iwamatsu , Stephen Boyd , Sasha Levin Subject: [PATCH 6.0 0427/1073] clk: visconti: Fix memory leak in visconti_register_pll() Date: Wed, 28 Dec 2022 15:33:35 +0100 Message-Id: <20221228144339.620969371@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221228144328.162723588@linuxfoundation.org> References: <20221228144328.162723588@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 b55226f8553d255f5002c751c7c6ba9291f34bf2 ] @pll->rate_table has allocated memory by kmemdup(), if clk_hw_register() fails, it should be freed, otherwise it will cause memory leak issue, this patch fixes it. Fixes: b4cbe606dc36 ("clk: visconti: Add support common clock driver and reset driver") Signed-off-by: Xiu Jianfeng Link: https://lore.kernel.org/r/20221122152353.204132-1-xiujianfeng@huawei.com Acked-by: Nobuhiro Iwamatsu Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/visconti/pll.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/clk/visconti/pll.c b/drivers/clk/visconti/pll.c index a484cb945d67..1f3234f22667 100644 --- a/drivers/clk/visconti/pll.c +++ b/drivers/clk/visconti/pll.c @@ -277,6 +277,7 @@ static struct clk_hw *visconti_register_pll(struct visconti_pll_provider *ctx, ret = clk_hw_register(NULL, &pll->hw); if (ret) { pr_err("failed to register pll clock %s : %d\n", name, ret); + kfree(pll->rate_table); kfree(pll); pll_hw_clk = ERR_PTR(ret); } -- 2.35.1