From a0399ce10ff56036476fa2d0f2a7062c19dda266 Mon Sep 17 00:00:00 2001 From: Declan Doherty Date: Wed, 17 Dec 2014 11:46:59 +0000 Subject: [PATCH] bond: check null before use Signed-off-by: Declan Doherty --- lib/librte_pmd_bond/rte_eth_bond_pmd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c index 3db473b4d7..bb4a53793d 100644 --- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c +++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c @@ -764,8 +764,6 @@ mac_address_get(struct rte_eth_dev *eth_dev, struct ether_addr *dst_mac_addr) { struct ether_addr *mac_addr; - mac_addr = eth_dev->data->mac_addrs; - if (eth_dev == NULL) { RTE_LOG(ERR, PMD, "%s: NULL pointer eth_dev specified\n", __func__); return -1; @@ -776,6 +774,8 @@ mac_address_get(struct rte_eth_dev *eth_dev, struct ether_addr *dst_mac_addr) return -1; } + mac_addr = eth_dev->data->mac_addrs; + ether_addr_copy(mac_addr, dst_mac_addr); return 0; } @@ -785,8 +785,6 @@ mac_address_set(struct rte_eth_dev *eth_dev, struct ether_addr *new_mac_addr) { struct ether_addr *mac_addr; - mac_addr = eth_dev->data->mac_addrs; - if (eth_dev == NULL) { RTE_BOND_LOG(ERR, "NULL pointer eth_dev specified"); return -1; @@ -797,6 +795,8 @@ mac_address_set(struct rte_eth_dev *eth_dev, struct ether_addr *new_mac_addr) return -1; } + mac_addr = eth_dev->data->mac_addrs; + /* If new MAC is different to current MAC then update */ if (memcmp(mac_addr, new_mac_addr, sizeof(*mac_addr)) != 0) memcpy(mac_addr, new_mac_addr, sizeof(*mac_addr)); -- 2.20.1