Skip to contentSkip to conversation

clk: pxa: fix NULL pointer dereference in pxa3xx_clk_update_accr

PATCH Applied Arnd Bergmann 2 participants 2 messages May 11, 2023 – Jun 15, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: pxa: fix NULL pointer dereference in pxa3xx_clk_update_accr

From: Arnd Bergmann <[email protected]>

sparse points out an embarrasing bug in an older patch of mine, which uses the register offset instead of an __iomem pointer:

drivers/clk/pxa/clk-pxa3xx.c:167:9: sparse: sparse: Using plain integer as NULL pointer

Unlike sparse, gcc and clang ignore this bug and fail to warn because a literal '0' is considered a valid representation of a NULL pointer.

Fixes 3c816d950a49 ("ARM: pxa: move clk register definitions to driver")
---
 drivers/clk/pxa/clk-pxa3xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/pxa/clk-pxa3xx.c +1 -1
index 42958a542662..621e298f101a 100644
@@ -164,7 +164,7 @@ void pxa3xx_clk_update_accr(u32 disable, u32 enable, u32 xclkcfg, u32 mask)
 	accr &= ~disable;
 	accr |= enable;
 
-	writel(accr, ACCR);
+	writel(accr, clk_regs + ACCR);
 	if (xclkcfg)
 		__asm__("mcr p14, 0, %0, c6, c0, 0\n" : : "r"(xclkcfg));
 
Signature · 1 line
2.39.2
maintainer Applied
#1 lore raw

Quoting Arnd Bergmann (2023-05-11 03:58:33)

Quoted 11 lines

From: Arnd Bergmann <[email protected]>

sparse points out an embarrasing bug in an older patch of mine, which uses the register offset instead of an __iomem pointer:

drivers/clk/pxa/clk-pxa3xx.c:167:9: sparse: sparse: Using plain integer as NULL pointer

Unlike sparse, gcc and clang ignore this bug and fail to warn because a literal '0' is considered a valid representation of a NULL pointer.

Quoted 6 lines
Fixes 3c816d950a49 ("ARM: pxa: move clk register definitions to driver")

---

Applied to clk-fixes