Skip to content

Commit 68bc74f

Browse files
nsekhardavem330
authored andcommitted
net: davinci_emac: fix oops caused by uninitialized ndev->dev
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 <khilman@linaro.org> Helped-by: George Cherian <george.cherian@ti.com> Signed-off-by: Sekhar Nori <nsekhar@ti.com> Acked-by: Mugunthan V N <mugunthanvnm@ti.com> Tested-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Tested-by: Kevin Hilman <khilman@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent cb421c2 commit 68bc74f

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

‎drivers/net/ethernet/ti/davinci_emac.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,7 +1865,6 @@ static int davinci_emac_probe(struct platform_device *pdev)
18651865
struct emac_priv *priv;
18661866
unsigned long hw_ram_addr;
18671867
struct emac_platform_data *pdata;
1868-
struct device *emac_dev;
18691868
struct cpdma_params dma_params;
18701869
struct clk *emac_clk;
18711870
unsigned long emac_bus_frequency;
@@ -1911,7 +1910,6 @@ static int davinci_emac_probe(struct platform_device *pdev)
19111910
priv->coal_intvl = 0;
19121911
priv->bus_freq_mhz = (u32)(emac_bus_frequency / 1000000);
19131912

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

19321930
memset(&dma_params, 0, sizeof(dma_params));
1933-
dma_params.dev = emac_dev;
1931+
dma_params.dev = &pdev->dev;
19341932
dma_params.dmaregs = priv->emac_base;
19351933
dma_params.rxthresh = priv->emac_base + 0x120;
19361934
dma_params.rxfree = priv->emac_base + 0x140;
@@ -1994,7 +1992,7 @@ static int davinci_emac_probe(struct platform_device *pdev)
19941992

19951993

19961994
if (netif_msg_probe(priv)) {
1997-
dev_notice(emac_dev, "DaVinci EMAC Probe found device "\
1995+
dev_notice(&pdev->dev, "DaVinci EMAC Probe found device "
19981996
"(regs: %p, irq: %d)\n",
19991997
(void *)priv->emac_base_phys, ndev->irq);
20001998
}

0 commit comments

Comments
 (0)