From: Andrew Goodbody Date: Tue, 29 Jul 2025 11:50:47 +0000 (+0100) Subject: socfpga_dtreg: Ensure reg is initialised before use X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e1cc5d861d388f5699859bac481822029881738;p=thirdparty%2Fu-boot.git socfpga_dtreg: Ensure reg is initialised before use In socfpga_dtreg_probe it is possible that if mask is 0 then reg will not be assigned to before first use. Refactor the code slightly to ensure that reg is always assigned to and remove a piece of duplicated code. This issue was found by Smatch. Signed-off-by: Andrew Goodbody --- diff --git a/drivers/misc/socfpga_dtreg.c b/drivers/misc/socfpga_dtreg.c index ea5d0bcdf51..dd6809433e3 100644 --- a/drivers/misc/socfpga_dtreg.c +++ b/drivers/misc/socfpga_dtreg.c @@ -76,16 +76,15 @@ static int socfpga_dtreg_probe(struct udevice *dev) return -EINVAL; } + reg = base + offset; + if (mask != 0) { if (mask == 0xffffffff) { - reg = base + offset; writel(val, (uintptr_t)reg); } else { /* Mask the value with the masking bits */ set_mask = val & mask; - reg = base + offset; - /* Clears and sets specific bits in the register */ clrsetbits_le32((uintptr_t)reg, mask, set_mask); }