aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Sverdlin <[email protected]>2022-01-30 16:25:02 +0100
committerArnd Bergmann <[email protected]>2022-04-07 13:55:52 +0200
commit3b68b08885217abd9c57ff9b3bb3eb173eee02a9 (patch)
tree958121dcf3624cd6a55ce35d07469f407426fddf
parentd10f4b22e912d9771493f71d05337362538eec07 (diff)
ep93xx: clock: Fix UAF in ep93xx_clk_register_gate()
arch/arm/mach-ep93xx/clock.c:154:2: warning: Use of memory after it is freed [clang-analyzer-unix.Malloc] arch/arm/mach-ep93xx/clock.c:151:2: note: Taking true branch if (IS_ERR(clk)) ^ arch/arm/mach-ep93xx/clock.c:152:3: note: Memory is released kfree(psc); ^~~~~~~~~~ arch/arm/mach-ep93xx/clock.c:154:2: note: Use of memory after it is freed return &psc->hw; ^ ~~~~~~~~ Fixes: 9645ccc7bd7a ("ep93xx: clock: convert in-place to COMMON_CLK") Reported-by: kernel test robot <[email protected]> Signed-off-by: Alexander Sverdlin <[email protected]> Cc: [email protected] Link: https://lists.01.org/hyperkitty/list/[email protected]/thread/B5YCO2NJEXINCYE26Y255LCVMO55BGWW/ Signed-off-by: Arnd Bergmann <[email protected]>
-rw-r--r--arch/arm/mach-ep93xx/clock.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/arch/arm/mach-ep93xx/clock.c b/arch/arm/mach-ep93xx/clock.c
index cc75087134d3..28e0ae6e890e 100644
--- a/arch/arm/mach-ep93xx/clock.c
+++ b/arch/arm/mach-ep93xx/clock.c
@@ -148,8 +148,10 @@ static struct clk_hw *ep93xx_clk_register_gate(const char *name,
psc->lock = &clk_lock;
clk = clk_register(NULL, &psc->hw);
- if (IS_ERR(clk))
+ if (IS_ERR(clk)) {
kfree(psc);
+ return ERR_CAST(clk);
+ }
return &psc->hw;
}