Commit 53de429f authored by Yizhuo's avatar Yizhuo Committed by David S. Miller
Browse files

net: hisilicon: Fix usage of uninitialized variable in function mdio_sc_cfg_reg_write()



In function mdio_sc_cfg_reg_write(), variable "reg_value" could be
uninitialized if regmap_read() fails. However, "reg_value" is used
to decide the control flow later in the if statement, which is
potentially unsafe.
Signed-off-by: default avatarYizhuo <yzhai003@ucr.edu>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4fbb97ba
...@@ -148,11 +148,15 @@ static int mdio_sc_cfg_reg_write(struct hns_mdio_device *mdio_dev, ...@@ -148,11 +148,15 @@ static int mdio_sc_cfg_reg_write(struct hns_mdio_device *mdio_dev,
{ {
u32 time_cnt; u32 time_cnt;
u32 reg_value; u32 reg_value;
int ret;
regmap_write(mdio_dev->subctrl_vbase, cfg_reg, set_val); regmap_write(mdio_dev->subctrl_vbase, cfg_reg, set_val);
for (time_cnt = MDIO_TIMEOUT; time_cnt; time_cnt--) { for (time_cnt = MDIO_TIMEOUT; time_cnt; time_cnt--) {
regmap_read(mdio_dev->subctrl_vbase, st_reg, &reg_value); ret = regmap_read(mdio_dev->subctrl_vbase, st_reg, &reg_value);
if (ret)
return ret;
reg_value &= st_msk; reg_value &= st_msk;
if ((!!check_st) == (!!reg_value)) if ((!!check_st) == (!!reg_value))
break; break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment