Most register accesses via the ksz_read* functions don't expect that they can fail and don't check for an error. This assumption is wrong if there is a problem with the underlying transport, e.g. an I2C bus. In that case, the functions would return an error code that mostly goes unchecked and *val is set to an uninitialized value. The original Linux driver suffers from a similar problem: There, *val is only set on success, but if the read fails, there's a warning printed to log, but still the uninitialized variable in the caller function will be used instead. This likely goes unnoticed, because GCC builds on Linux have -Wno-maybe-uninitialized, but we have implicit -W-maybe-uninitialized in barebox. As we sync the code from Linux, one should probably fix this there first, but let's improve the situation a bit by not reporting an uninitialized value, but a deterministic zero. Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- drivers/net/ksz_common.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ksz_common.h b/drivers/net/ksz_common.h index 291488fe3485..44b5055ee397 100644 --- a/drivers/net/ksz_common.h +++ b/drivers/net/ksz_common.h @@ -20,7 +20,7 @@ struct ksz_switch { static inline int ksz_read8(struct ksz_switch *priv, u32 reg, u8 *val) { - unsigned int value; + unsigned int value = 0; int ret = regmap_read(priv->regmap[0], reg, &value); *val = value; @@ -29,7 +29,7 @@ static inline int ksz_read8(struct ksz_switch *priv, u32 reg, u8 *val) static inline int ksz_read16(struct ksz_switch *priv, u32 reg, u16 *val) { - unsigned int value; + unsigned int value = 0; int ret = regmap_read(priv->regmap[1], reg, &value); *val = value; @@ -38,7 +38,7 @@ static inline int ksz_read16(struct ksz_switch *priv, u32 reg, u16 *val) static inline int ksz_read32(struct ksz_switch *priv, u32 reg, u32 *val) { - unsigned int value; + unsigned int value = 0; int ret = regmap_read(priv->regmap[2], reg, &value); *val = value; -- 2.39.2