In function sun8i_dwmac_set_syscon(), local variable "val" could
be uninitialized if function regmap_read() returns -EINVAL.
However, it will be used directly in the if statement, which
is potentially unsafe.
Signed-off-by: Yizhuo <[email protected]>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 39c2122a4f26..50cfd6d83052 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -641,7 +641,12 @@ static int sun8i_dwmac_set_syscon(struct stmmac_priv *priv)
int ret;
u32 reg, val;
- regmap_read(gmac->regmap, SYSCON_EMAC_REG, &val);
+ ret = regmap_read(gmac->regmap, SYSCON_EMAC_REG, &val);
+ if (ret) {
+ dev_err(priv->device, "Fail to read SYSCON_EMAC_REG.\n");
+ return ret;
+ }
+
reg = gmac->variant->default_syscon_value;
if (reg != val)
dev_warn(priv->device,
--
2.17.1
From: Yizhuo Zhai <[email protected]>
Date: Wed, 6 Feb 2019 21:52:15 -0800
> Thanks, but why initialization matters here? Is performance the main
> concern?
Code that is unnecessary is hard to audit.
People will ask "why" is it initialized? In what situations is the
initialized value of "0" ever used?
You are wasting people's time and energy by writing unnecessary code.
On Thu, Feb 07, 2019 at 09:46:23AM -0800, Yizhuo wrote:
> In function sun8i_dwmac_set_syscon(), local variable "val" could
> be uninitialized if function regmap_read() returns -EINVAL.
> However, it will be used directly in the if statement, which
> is potentially unsafe.
>
> Signed-off-by: Yizhuo <[email protected]>
Acked-by: Maxime Ripard <[email protected]>
Thanks!
Maxime
--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
From: Yizhuo <[email protected]>
Date: Thu, 7 Feb 2019 09:46:23 -0800
> In function sun8i_dwmac_set_syscon(), local variable "val" could
> be uninitialized if function regmap_read() returns -EINVAL.
> However, it will be used directly in the if statement, which
> is potentially unsafe.
>
> Signed-off-by: Yizhuo <[email protected]>
This doesn't apply to any of my trees.
Hi David:
Thanks for your feedback, this patch should work for v4.14.
On Fri, Feb 8, 2019 at 11:01 PM David Miller <[email protected]> wrote:
>
> From: Yizhuo <[email protected]>
> Date: Thu, 7 Feb 2019 09:46:23 -0800
>
> > In function sun8i_dwmac_set_syscon(), local variable "val" could
> > be uninitialized if function regmap_read() returns -EINVAL.
> > However, it will be used directly in the if statement, which
> > is potentially unsafe.
> >
> > Signed-off-by: Yizhuo <[email protected]>
>
> This doesn't apply to any of my trees.
--
Kind Regards,
Yizhuo Zhai
Computer Science, Graduate Student
University of California, Riverside
From: Yizhuo Zhai <[email protected]>
Date: Fri, 30 Aug 2019 15:29:07 -0700
> Thanks for your feedback, this patch should work for v4.14.
You must always submit patches against the current tree.