Skip to content

Commit e33b432

Browse files
Yizhuodavem330
authored andcommitted
net: stmmac: dwmac-sun8i: Variable "val" in function sun8i_dwmac_set_syscon() could be uninitialized
In function sun8i_dwmac_set_syscon(), local variable "val" could be uninitialized if function regmap_field_read() returns -EINVAL. However, it will be used directly in the if statement, which is potentially unsafe. Signed-off-by: Yizhuo <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 089cf7f commit e33b432

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,12 @@ static int sun8i_dwmac_set_syscon(struct stmmac_priv *priv)
873873
int ret;
874874
u32 reg, val;
875875

876-
regmap_field_read(gmac->regmap_field, &val);
876+
ret = regmap_field_read(gmac->regmap_field, &val);
877+
if (ret) {
878+
dev_err(priv->device, "Fail to read from regmap field.\n");
879+
return ret;
880+
}
881+
877882
reg = gmac->variant->default_syscon_value;
878883
if (reg != val)
879884
dev_warn(priv->device,

0 commit comments

Comments
 (0)