[PATCH] ARM: sa1100: Fix a wild pointer dereference in sa11xx_clk_init()

Zhou Qingyang zhou1615 at umn.edu
Tue Nov 30 00:34:11 PST 2021


In sa11xx_clk_init(), the return value of clk_hw_register_mux() is
assigned to hw, and there is a dereference of it in sa11xx_clk_init().
clk_hw_register_mux() is a wrapper of __clk_hw_register_mux(), which
could return a ERR_PTR on error, and lead to a wild pointer dereference.

Fix this bug by adding a return value check.

This bug was found by a static analyzer. The analysis employs
differential checking to identify inconsistent security operations
(e.g., checks or kfrees) between two code paths and confirms that the
inconsistent operations are not recovered in the current function or
the callers, so they constitute bugs.

Note that, as a bug found by static analysis, it can be a false
positive or hard to trigger. Multiple researchers have cross-reviewed
the bug.

Since I do not have a sa1100 machine, I can not actually evaluate this
patch.

Fixes: d6c8204659eb ("ARM: sa1100: convert to common clock framework")
Signed-off-by: Zhou Qingyang <zhou1615 at umn.edu>
---
 arch/arm/mach-sa1100/clock.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/mach-sa1100/clock.c b/arch/arm/mach-sa1100/clock.c
index e8691921c69a..5b4d8e556ad2 100644
--- a/arch/arm/mach-sa1100/clock.c
+++ b/arch/arm/mach-sa1100/clock.c
@@ -127,6 +127,9 @@ int __init sa11xx_clk_init(void)
 				 ARRAY_SIZE(clk_tucr_parents), 0,
 				 (void __iomem *)&TUCR, FShft(TUCR_TSEL),
 				 FAlnMsk(TUCR_TSEL), 0, &tucr_lock);
+	if (IS_ERR(hw))
+		return PTR_ERR(hw);
+
 	clk_set_rate(hw->clk, 3686400);
 
 	hw = kzalloc(sizeof(*hw), GFP_KERNEL);
-- 
2.25.1




More information about the linux-arm-kernel mailing list