Skip to content

Commit

Permalink
net: davinci_emac: fix oops caused by uninitialized ndev->dev
Browse files Browse the repository at this point in the history
Commit e194312 (drivers: net:
davinci_cpdma: Convert kzalloc() to devm_kzalloc()) triggered
a bug in emac_probe() wherein dev member of net_device is used
for devres allocations even before it is initialized.

This patch fixes that by using the struct device in platform_device
instead.

While at it, use &pdev->dev consistently for console messages instead
of using ndev->dev for just one case and remove an unnecessary line
continuation.

Reported-by: Kevin Hilman <[email protected]>
Helped-by: George Cherian <[email protected]>
Signed-off-by: Sekhar Nori <[email protected]>
Acked-by: Mugunthan V N <[email protected]>
Tested-by: Lad, Prabhakar <[email protected]>
Tested-by: Kevin Hilman <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
nsekhar authored and davem330 committed May 22, 2014
1 parent cb421c2 commit 68bc74f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions drivers/net/ethernet/ti/davinci_emac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1865,7 +1865,6 @@ static int davinci_emac_probe(struct platform_device *pdev)
struct emac_priv *priv;
unsigned long hw_ram_addr;
struct emac_platform_data *pdata;
struct device *emac_dev;
struct cpdma_params dma_params;
struct clk *emac_clk;
unsigned long emac_bus_frequency;
Expand Down Expand Up @@ -1911,7 +1910,6 @@ static int davinci_emac_probe(struct platform_device *pdev)
priv->coal_intvl = 0;
priv->bus_freq_mhz = (u32)(emac_bus_frequency / 1000000);

emac_dev = &ndev->dev;
/* Get EMAC platform data */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
priv->emac_base_phys = res->start + pdata->ctrl_reg_offset;
Expand All @@ -1930,7 +1928,7 @@ static int davinci_emac_probe(struct platform_device *pdev)
hw_ram_addr = (u32 __force)res->start + pdata->ctrl_ram_offset;

memset(&dma_params, 0, sizeof(dma_params));
dma_params.dev = emac_dev;
dma_params.dev = &pdev->dev;
dma_params.dmaregs = priv->emac_base;
dma_params.rxthresh = priv->emac_base + 0x120;
dma_params.rxfree = priv->emac_base + 0x140;
Expand Down Expand Up @@ -1994,7 +1992,7 @@ static int davinci_emac_probe(struct platform_device *pdev)


if (netif_msg_probe(priv)) {
dev_notice(emac_dev, "DaVinci EMAC Probe found device "\
dev_notice(&pdev->dev, "DaVinci EMAC Probe found device "
"(regs: %p, irq: %d)\n",
(void *)priv->emac_base_phys, ndev->irq);
}
Expand Down

0 comments on commit 68bc74f

Please sign in to comment.