a42e9aa354a69b5cb9613af0735381fcaafa76a0
[openwrt/staging/blocktrron.git] /
1 From 1ccc18ca96d8a824f2af45d1046d23ccdb90f3df Mon Sep 17 00:00:00 2001
2 From: Anji Jagarlmudi <anji.jagarlmudi@nxp.com>
3 Date: Wed, 8 Jan 2020 12:18:40 +0530
4 Subject: [PATCH] staging: fsl_ppfe/eth: Enhance error checking in platform
5 probe
6
7 Fix the kernel crash when MAC addr is not passed in dtb.
8
9 Signed-off-by: Anji Jagarlmudi <anji.jagarlmudi@nxp.com>
10 ---
11 drivers/staging/fsl_ppfe/pfe_ls1012a_platform.c | 10 +++++++---
12 1 file changed, 7 insertions(+), 3 deletions(-)
13
14 --- a/drivers/staging/fsl_ppfe/pfe_ls1012a_platform.c
15 +++ b/drivers/staging/fsl_ppfe/pfe_ls1012a_platform.c
16 @@ -29,15 +29,19 @@ static int pfe_get_gemac_if_properties(s
17 int size;
18 int phy_id = 0;
19 const u32 *addr;
20 - const void *mac_addr;
21 + const u8 *mac_addr;
22
23 addr = of_get_property(gem, "reg", &size);
24 - port = be32_to_cpup(addr);
25 + if (addr)
26 + port = be32_to_cpup(addr);
27 + else
28 + goto err;
29 +
30
31 pdata->ls1012a_eth_pdata[port].gem_id = port;
32
33 mac_addr = of_get_mac_address(gem);
34 - if (mac_addr) {
35 + if (!IS_ERR_OR_NULL(mac_addr)) {
36 memcpy(pdata->ls1012a_eth_pdata[port].mac_addr, mac_addr,
37 ETH_ALEN);
38 }