1
0
Fork 0

staging: fsl_ppfe/eth: Enhance error checking in platform probe

Fix the kernel crash when MAC addr is not passed in dtb.

Signed-off-by: Anji Jagarlmudi <anji.jagarlmudi@nxp.com>
(cherry picked from commit 2be5e9c740060b58e962db4c9c20161b0c656ea9)
5.4-rM2-2.2.x-imx-squashed
Anji Jagarlmudi 2020-01-08 12:18:40 +05:30 committed by Jason Liu
parent 65dccc3684
commit 01868891ee
1 changed files with 7 additions and 3 deletions

View File

@ -29,15 +29,19 @@ static int pfe_get_gemac_if_properties(struct device_node *gem,
int size;
int phy_id = 0;
const u32 *addr;
const void *mac_addr;
const u8 *mac_addr;
addr = of_get_property(gem, "reg", &size);
port = be32_to_cpup(addr);
if (addr)
port = be32_to_cpup(addr);
else
goto err;
pdata->ls1012a_eth_pdata[port].gem_id = port;
mac_addr = of_get_mac_address(gem);
if (mac_addr) {
if (!IS_ERR_OR_NULL(mac_addr)) {
memcpy(pdata->ls1012a_eth_pdata[port].mac_addr, mac_addr,
ETH_ALEN);
}