nvethernet: Error check for mac address DT node

Issue:
Incorrect return value check for of_get_mac_address()
when reading mac address from dt property.

Fix:
1. Modify error check condition based on
of_get_mac_address() return values.
2. Fixes the Coverity defect CID 10166538.

Bug 3952896

Change-Id: I65ddd05538ad3039da2a21a79be8bb7a0ed1f3fc
Signed-off-by: Sushil Kumar Singh <sushilkumars@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2857036
Reviewed-by: Bhadram Varka <vbhadram@nvidia.com>
Reviewed-by: Narayan Reddy <narayanr@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Sushil Kumar Singh
2023-02-13 01:11:37 +05:30
committed by mobile promotions
parent d89c0fcf3b
commit 877d53d041

View File

@@ -4662,23 +4662,11 @@ static int ether_get_mac_address(struct ether_priv_data *pdata)
* MAC address
*/
ret = of_get_mac_address(np, addr);
if (!ret)
if (ret < 0) {
dev_err(dev, "No Mac address local DT!\n");
return ret;
}
eth_mac_addr = addr;
if (IS_ERR_OR_NULL(eth_mac_addr)) {
dev_err(dev, "No MAC address in local DT!\n");
return -EINVAL;
}
}
/* If neither chosen node nor kernel supported dt strings are
* present in platform device tree.
*/
if (!(is_valid_ether_addr(eth_mac_addr)) ||
IS_ERR_OR_NULL(eth_mac_addr)) {
dev_err(dev, "Bad mac address exiting\n");
return -EINVAL;
}
/* Found a valid mac address */