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 31DBB73161; Wed, 21 Feb 2024 14:24:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708525473; cv=none; b=nEwUwlwYo9cH4ihQn4Gb6NdO7D6FbcZO3MJCFZGiF864cCq7LsWw3HKuE1gqA3LMNQTDNAOuExGvLksc7KgUofVeAcSkioe6lrIbGzhfSPaDOSN03XpC/g8sftq6fh53P1xOqv5bel8W8V5wUGWpGxAHe65zuQmHHtDZKhvpf18= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708525473; c=relaxed/simple; bh=Y1UIyO7SNY7t+rLUyMbDrX5+1R4jDzHRhpM9NLh6/HA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cd5iSDvDfWoKuEZ0pne/4u0FJVH7WVvNlKdy5TcDii4JI2CQMgK37demJ4but/1Bx6qV9chp4ktgbBB6gC2o/eLhrRgzikzoGLQ2lh2oRhIfT0W28854JVueoF015f6b/tnnKsB9yWmh4oWShjZtEpca0p8oqLS2JRM794J6N1s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Wg1aSCJn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Wg1aSCJn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28C83C433C7; Wed, 21 Feb 2024 14:24:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1708525470; bh=Y1UIyO7SNY7t+rLUyMbDrX5+1R4jDzHRhpM9NLh6/HA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wg1aSCJnH5ZjMLpa+WuK2Kc1ZAM7fH/5R1v8nvH6Mz+J+bLqJFSo80AnMwi/t4Gdy X1WIRPtC/Q1n2zAj1adwNoEyeAKWEHGwB1jrZkH6X/L1J8cwJk/cU1cgvHenBvNNNr BODxl2nAbtCLrJPa0MhiDgwyQ3kdRrabBn+vLLNk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kuan-Wei Chiu , Stephen Boyd , Sasha Levin Subject: [PATCH 5.4 136/267] clk: mmp: pxa168: Fix memory leak in pxa168_clk_init() Date: Wed, 21 Feb 2024 14:07:57 +0100 Message-ID: <20240221125944.322700093@linuxfoundation.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240221125940.058369148@linuxfoundation.org> References: <20240221125940.058369148@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kuan-Wei Chiu [ Upstream commit 2fbabea626b6467eb4e6c4cb7a16523da12e43b4 ] In cases where mapping of mpmu/apmu/apbc registers fails, the code path does not handle the failure gracefully, potentially leading to a memory leak. This fix ensures proper cleanup by freeing the allocated memory for 'pxa_unit' before returning. Signed-off-by: Kuan-Wei Chiu Link: https://lore.kernel.org/r/20231210175232.3414584-1-visitorckw@gmail.com Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/mmp/clk-of-pxa168.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/clk/mmp/clk-of-pxa168.c b/drivers/clk/mmp/clk-of-pxa168.c index f110c02e83cb..9674c6c06dca 100644 --- a/drivers/clk/mmp/clk-of-pxa168.c +++ b/drivers/clk/mmp/clk-of-pxa168.c @@ -258,18 +258,21 @@ static void __init pxa168_clk_init(struct device_node *np) pxa_unit->mpmu_base = of_iomap(np, 0); if (!pxa_unit->mpmu_base) { pr_err("failed to map mpmu registers\n"); + kfree(pxa_unit); return; } pxa_unit->apmu_base = of_iomap(np, 1); if (!pxa_unit->apmu_base) { pr_err("failed to map apmu registers\n"); + kfree(pxa_unit); return; } pxa_unit->apbc_base = of_iomap(np, 2); if (!pxa_unit->apbc_base) { pr_err("failed to map apbc registers\n"); + kfree(pxa_unit); return; } -- 2.43.0