Skip to content

Commit

Permalink
net: stmmac: dwmac-sun8i: Variable "val" in function sun8i_dwmac_set_…
Browse files Browse the repository at this point in the history
…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]>
  • Loading branch information
Yizhuo authored and davem330 committed Sep 2, 2019
1 parent 089cf7f commit e33b432
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,12 @@ static int sun8i_dwmac_set_syscon(struct stmmac_priv *priv)
int ret;
u32 reg, val;

regmap_field_read(gmac->regmap_field, &val);
ret = regmap_field_read(gmac->regmap_field, &val);
if (ret) {
dev_err(priv->device, "Fail to read from regmap field.\n");
return ret;
}

reg = gmac->variant->default_syscon_value;
if (reg != val)
dev_warn(priv->device,
Expand Down

0 comments on commit e33b432

Please sign in to comment.