]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: stmmac: dwmac-sun8i: Variable "val" in function sun8i_dwmac_set_syscon() could...
authorYizhuo <yzhai003@ucr.edu>
Sat, 31 Aug 2019 02:00:48 +0000 (19:00 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 2 Sep 2019 18:48:15 +0000 (11:48 -0700)
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 <yzhai003@ucr.edu>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c

index 4083019c547a4b1b04509738ac4a6cb4ee0808e5..f97a4096f8fc8e44ef2456e822952a885e48de83 100644 (file)
@@ -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,