mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-01 06:33:07 +00:00
Merge branch 'mtk_eth_wed-leak-fixes'
Yang Yingliang says: ==================== net: ethernet: mtk_eth_wed: fixe some leaks I found some leaks in mtk_eth_soc.c/mtk_wed.c. patch#1 - I found mtk_wed_exit() is never called, I think mtk_wed_exit() need be called in error path or module remove function to free the memory allocated in mtk_wed_add_hw(). patch#2 - The device is not put in error path in mtk_wed_add_hw(). patch#3 - The device_node pointer returned by of_parse_phandle() with refcount incremented, it should be decreased when it done. This patchset was just compiled tested because I don't have any HW on which to do the actual tests. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
a887b59f6a
2 changed files with 24 additions and 8 deletions
|
@ -4060,19 +4060,23 @@ static int mtk_probe(struct platform_device *pdev)
|
||||||
eth->irq[i] = platform_get_irq(pdev, i);
|
eth->irq[i] = platform_get_irq(pdev, i);
|
||||||
if (eth->irq[i] < 0) {
|
if (eth->irq[i] < 0) {
|
||||||
dev_err(&pdev->dev, "no IRQ%d resource found\n", i);
|
dev_err(&pdev->dev, "no IRQ%d resource found\n", i);
|
||||||
return -ENXIO;
|
err = -ENXIO;
|
||||||
|
goto err_wed_exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; i < ARRAY_SIZE(eth->clks); i++) {
|
for (i = 0; i < ARRAY_SIZE(eth->clks); i++) {
|
||||||
eth->clks[i] = devm_clk_get(eth->dev,
|
eth->clks[i] = devm_clk_get(eth->dev,
|
||||||
mtk_clks_source_name[i]);
|
mtk_clks_source_name[i]);
|
||||||
if (IS_ERR(eth->clks[i])) {
|
if (IS_ERR(eth->clks[i])) {
|
||||||
if (PTR_ERR(eth->clks[i]) == -EPROBE_DEFER)
|
if (PTR_ERR(eth->clks[i]) == -EPROBE_DEFER) {
|
||||||
return -EPROBE_DEFER;
|
err = -EPROBE_DEFER;
|
||||||
|
goto err_wed_exit;
|
||||||
|
}
|
||||||
if (eth->soc->required_clks & BIT(i)) {
|
if (eth->soc->required_clks & BIT(i)) {
|
||||||
dev_err(&pdev->dev, "clock %s not found\n",
|
dev_err(&pdev->dev, "clock %s not found\n",
|
||||||
mtk_clks_source_name[i]);
|
mtk_clks_source_name[i]);
|
||||||
return -EINVAL;
|
err = -EINVAL;
|
||||||
|
goto err_wed_exit;
|
||||||
}
|
}
|
||||||
eth->clks[i] = NULL;
|
eth->clks[i] = NULL;
|
||||||
}
|
}
|
||||||
|
@ -4083,7 +4087,7 @@ static int mtk_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
err = mtk_hw_init(eth);
|
err = mtk_hw_init(eth);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
goto err_wed_exit;
|
||||||
|
|
||||||
eth->hwlro = MTK_HAS_CAPS(eth->soc->caps, MTK_HWLRO);
|
eth->hwlro = MTK_HAS_CAPS(eth->soc->caps, MTK_HWLRO);
|
||||||
|
|
||||||
|
@ -4179,6 +4183,8 @@ static int mtk_probe(struct platform_device *pdev)
|
||||||
mtk_free_dev(eth);
|
mtk_free_dev(eth);
|
||||||
err_deinit_hw:
|
err_deinit_hw:
|
||||||
mtk_hw_deinit(eth);
|
mtk_hw_deinit(eth);
|
||||||
|
err_wed_exit:
|
||||||
|
mtk_wed_exit();
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -4198,6 +4204,7 @@ static int mtk_remove(struct platform_device *pdev)
|
||||||
phylink_disconnect_phy(mac->phylink);
|
phylink_disconnect_phy(mac->phylink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mtk_wed_exit();
|
||||||
mtk_hw_deinit(eth);
|
mtk_hw_deinit(eth);
|
||||||
|
|
||||||
netif_napi_del(ð->tx_napi);
|
netif_napi_del(ð->tx_napi);
|
||||||
|
|
|
@ -1072,16 +1072,16 @@ void mtk_wed_add_hw(struct device_node *np, struct mtk_eth *eth,
|
||||||
|
|
||||||
pdev = of_find_device_by_node(np);
|
pdev = of_find_device_by_node(np);
|
||||||
if (!pdev)
|
if (!pdev)
|
||||||
return;
|
goto err_of_node_put;
|
||||||
|
|
||||||
get_device(&pdev->dev);
|
get_device(&pdev->dev);
|
||||||
irq = platform_get_irq(pdev, 0);
|
irq = platform_get_irq(pdev, 0);
|
||||||
if (irq < 0)
|
if (irq < 0)
|
||||||
return;
|
goto err_put_device;
|
||||||
|
|
||||||
regs = syscon_regmap_lookup_by_phandle(np, NULL);
|
regs = syscon_regmap_lookup_by_phandle(np, NULL);
|
||||||
if (IS_ERR(regs))
|
if (IS_ERR(regs))
|
||||||
return;
|
goto err_put_device;
|
||||||
|
|
||||||
rcu_assign_pointer(mtk_soc_wed_ops, &wed_ops);
|
rcu_assign_pointer(mtk_soc_wed_ops, &wed_ops);
|
||||||
|
|
||||||
|
@ -1124,8 +1124,16 @@ void mtk_wed_add_hw(struct device_node *np, struct mtk_eth *eth,
|
||||||
|
|
||||||
hw_list[index] = hw;
|
hw_list[index] = hw;
|
||||||
|
|
||||||
|
mutex_unlock(&hw_lock);
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
unlock:
|
unlock:
|
||||||
mutex_unlock(&hw_lock);
|
mutex_unlock(&hw_lock);
|
||||||
|
err_put_device:
|
||||||
|
put_device(&pdev->dev);
|
||||||
|
err_of_node_put:
|
||||||
|
of_node_put(np);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mtk_wed_exit(void)
|
void mtk_wed_exit(void)
|
||||||
|
@ -1146,6 +1154,7 @@ void mtk_wed_exit(void)
|
||||||
hw_list[i] = NULL;
|
hw_list[i] = NULL;
|
||||||
debugfs_remove(hw->debugfs_dir);
|
debugfs_remove(hw->debugfs_dir);
|
||||||
put_device(hw->dev);
|
put_device(hw->dev);
|
||||||
|
of_node_put(hw->node);
|
||||||
kfree(hw);
|
kfree(hw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue