diff options
author | Ziyang Xuan <william.xuanziyang@huawei.com> | 2022-11-11 10:09:35 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2022-11-14 13:55:43 +0300 |
commit | 848ffce2f0c93f3481052340a919123a21f808b6 (patch) | |
tree | 7cf0213b49b6c2672068a221646dfcaec7a524ce /drivers/net/ethernet | |
parent | e4041be97b15302ebfffda8bbd45f3b2d096048f (diff) | |
download | linux-848ffce2f0c93f3481052340a919123a21f808b6.tar.xz |
octeon_ep: ensure get mac address successfully before eth_hw_addr_set()
octep_get_mac_addr() can fail because send mbox message failed. If this
happens, octep_dev->mac_addr will be zero. It should not continue to
initialize. Add exception handling for octep_get_mac_addr() to fix it.
Fixes: 862cd659a6fb ("octeon_ep: Add driver framework and device initialization")
Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r-- | drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c index 53f288c32238..b45dd7f04e21 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c @@ -1072,7 +1072,11 @@ static int octep_probe(struct pci_dev *pdev, const struct pci_device_id *ent) netdev->max_mtu = OCTEP_MAX_MTU; netdev->mtu = OCTEP_DEFAULT_MTU; - octep_get_mac_addr(octep_dev, octep_dev->mac_addr); + err = octep_get_mac_addr(octep_dev, octep_dev->mac_addr); + if (err) { + dev_err(&pdev->dev, "Failed to get mac address\n"); + goto register_dev_err; + } eth_hw_addr_set(netdev, octep_dev->mac_addr); err = register_netdev(netdev); |