Skip to content

Commit 3b68b08

Browse files
sverdlinarndb
authored andcommitted
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: 9645ccc ("ep93xx: clock: convert in-place to COMMON_CLK") Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com> Cc: stable@vger.kernel.org Link: https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org/thread/B5YCO2NJEXINCYE26Y255LCVMO55BGWW/ Signed-off-by: Arnd Bergmann <arnd@arndb.de>
1 parent d10f4b2 commit 3b68b08

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

arch/arm/mach-ep93xx/clock.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,10 @@ static struct clk_hw *ep93xx_clk_register_gate(const char *name,
148148
psc->lock = &clk_lock;
149149

150150
clk = clk_register(NULL, &psc->hw);
151-
if (IS_ERR(clk))
151+
if (IS_ERR(clk)) {
152152
kfree(psc);
153+
return ERR_CAST(clk);
154+
}
153155

154156
return &psc->hw;
155157
}

0 commit comments

Comments
 (0)