Skip to content

Commit

Permalink
net: stmmac: dwmac-visconti: No change to ETHER_CLOCK_SEL for unexpec…
Browse files Browse the repository at this point in the history
…ted speed request.

Variable clk_sel_val is not initialized in the default case of the first switch statement.
In that case, the function should return immediately without any changes to the hardware.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: b38dd98 ("net: stmmac: Add Toshiba Visconti SoCs glue driver")
Signed-off-by: Yuji Ishikawa <yuji2.ishikawa@toshiba.co.jp>
Reviewed-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Yuji Ishikawa authored and David S. Miller committed Jan 28, 2022
1 parent 7674b7b commit 928d6fe
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ struct visconti_eth {
void __iomem *reg;
u32 phy_intf_sel;
struct clk *phy_ref_clk;
struct device *dev;
spinlock_t lock; /* lock to protect register update */
};

static void visconti_eth_fix_mac_speed(void *priv, unsigned int speed)
{
struct visconti_eth *dwmac = priv;
unsigned int val, clk_sel_val;
struct net_device *netdev = dev_get_drvdata(dwmac->dev);
unsigned int val, clk_sel_val = 0;
unsigned long flags;

spin_lock_irqsave(&dwmac->lock, flags);
Expand Down Expand Up @@ -85,7 +87,9 @@ static void visconti_eth_fix_mac_speed(void *priv, unsigned int speed)
break;
default:
/* No bit control */
break;
netdev_err(netdev, "Unsupported speed request (%d)", speed);
spin_unlock_irqrestore(&dwmac->lock, flags);
return;
}

writel(val, dwmac->reg + MAC_CTRL_REG);
Expand Down Expand Up @@ -229,6 +233,7 @@ static int visconti_eth_dwmac_probe(struct platform_device *pdev)

spin_lock_init(&dwmac->lock);
dwmac->reg = stmmac_res.addr;
dwmac->dev = &pdev->dev;
plat_dat->bsp_priv = dwmac;
plat_dat->fix_mac_speed = visconti_eth_fix_mac_speed;

Expand Down

0 comments on commit 928d6fe

Please sign in to comment.