Skip to content

Commit

Permalink
net: xilinx_emacps: Fixed accessing NULL pointer error when local-mac…
Browse files Browse the repository at this point in the history
…-address is not available in device tree
  • Loading branch information
Tinghui WANG (Steven) committed Jan 16, 2013
1 parent 220a757 commit 06b3889
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/net/ethernet/xilinx/xilinx_emacps.c
Original file line number Diff line number Diff line change
Expand Up @@ -2919,6 +2919,7 @@ static int __devinit xemacps_probe(struct platform_device *pdev)
u32 regval = 0;
int rc = -ENXIO;
int size = 0;
const u8* addr;

r_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
r_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
Expand Down Expand Up @@ -3065,10 +3066,11 @@ static int __devinit xemacps_probe(struct platform_device *pdev)
goto err_out_unregister_clk_notifier;
}

lp->ndev->dev_addr = of_get_property(lp->pdev->dev.of_node, "local-mac-address", &size);
if ((!lp->ndev->dev_addr) || (size != 6)) {
addr = of_get_property(lp->pdev->dev.of_node, "local-mac-address", &size);
if ((!addr) || (size != 6)) {
dev_warn(&lp->pdev->dev, "Could not find MAC address in device tree, use default\n");
} else {
memcpy(lp->ndev->dev_addr, addr, sizeof(addr));
xemacps_set_hwaddr(lp);
}
xemacps_update_hwaddr(lp);
Expand Down

0 comments on commit 06b3889

Please sign in to comment.